Note: This article assumes that you know PHP and how to customize WordPress themes.

I based my religious/social/politics blog What Matters to Me on something I noticed on another blog – summary headlines. I liked the idea of summaries that weren’t just the first so-many words of the article. They look more professional. WMTM also provides a RSS newsfeed. This is where the summary is also displayed. The purpose of creating a custom theme is to have a WordPress website that caters to your needs. The method of adding summaries that I used was the easiest I could find and isn’t hard to do.

There are plenty of websites that instruct you on how to create a custom plugin that can be called by your theme. I used an existing plugin called Meta Box. After installing and activating Meta Box, all that is necessary is adding code to the editable theme file called functions.php. After adding the code, restarting WordPress will register the new function and the custom text box will be added to the Add New Post and Edit Post pages.

Assuming Meta Box is activated on your WP website, edit your functions.php. I will show you mine as an example. Meta Box provides extensive tutorials.

<?php
    // Loading in scripts
    function enqueue_customtheme_styles() {
        wp_enqueue_style(‘bootstrap’, ‘//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css’);
        wp_enqueue_style(‘googlefont’, ‘//fonts.googleapis.com/css?family=Special+Elite|Racing+Sans+One|IM+Fell+English+SC’);
        wp_enqueue_style(‘customtheme-style’, get_stylesheet_uri());
        wp_enqueue_script(‘bootstrap-js’, ‘//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js’, array(‘jquery’));
    }
   
    add_action(‘wp_enqueue_scripts’, ‘enqueue_customtheme_styles’);
   
   
    function customtheme_setup() {
        // Register a custom primary navigation menu
        register_nav_menus(array(
            ‘primary’ => __(‘About Pages’, ‘customTheme’)   
        ));
       
        // Register a custom secondary navigation menu
        register_nav_menus(array(
            ‘secondary’ => __(‘Waves’, ‘customTheme’)   
        ));
       
        //Add theme support for website title and RSS feeds
        add_theme_support(‘title-tag’);
        add_theme_support(‘automatic-feed-links’);
    }
   
    add_action(‘after_setup_theme’, ‘customtheme_setup’);
   
    function customtheme_widgets() {
        register_sidebar( array(
            ‘name’          =>  __(‘Sidebar’, ‘customTheme’),
            ‘id’            =>  ‘sidebar-1’,
            ‘description’   =>  __(‘Add widgets here for sidebar’, ‘customTheme’),
            ‘before_widget’ =>  ‘<section id=”%1$s” class=”widget %2$s”>’,
            ‘after_widget’  =>  ‘</section>’,
            ‘before_title’  =>  ‘<h2 class=”widget-title”>’,
            ‘after_title’   =>  ‘</h2>’
        ));
    }
   
    add_action(‘widgets_init’, ‘customtheme_widgets’);
   
    function customtheme_widgets_2() {
        register_sidebar( array(
            ‘name’          =>  __(‘Sidebar2’, ‘customTheme’),
            ‘id’            =>  ‘sidebar-2’,
            ‘description’   =>  __(‘Add widgets here for sidebar’, ‘customTheme’),
            ‘before_widget’ =>  ‘<section id=”%1$s” class=”widget %2$s”>’,
            ‘after_widget’  =>  ‘</section>’,
            ‘before_title’  =>  ‘<h2 class=”widget-title”>’,
            ‘after_title’   =>  ‘</h2>’
        ));
    }
   
    add_action(‘widgets_init’, ‘customtheme_widgets_2’);
    remove_all_actions( ‘do_feed_rss2’ );
    add_action( ‘do_feed_rss2’, ‘customTheme_feed_rss2’, 10, 1 );
    function customTheme_feed_rss2( $for_comments ) {
        $rss_template = get_template_directory() . ‘/feed-customtheme-rss2.php’;
        if( file_exists( $rss_template ) )
            load_template( $rss_template );
        else
            do_feed_rss2( $for_comments ); // Call default function
    }
 
    add_filter( ‘rwmb_meta_boxes’, ‘your_prefix_meta_boxes’ );
    function your_prefix_meta_boxes( $meta_boxes ) {
        $meta_boxes[] = array(
            ‘title’      => __( ‘Summary’, ‘textdomain’ ),
            ‘post_types’ => ‘post’,
            ‘fields’     => array(
                array(
                    ‘id’   => ‘summary’,
                    ‘name’ => __( ‘Summary’, ‘textdomain’ ),
                    ‘type’ => ‘textarea’,
                ),
            ),
        );
        return $meta_boxes;
    }
    if( ! function_exists( ‘custom_shortcode’)) :
        function custom_shortcode( $atts, $content = null) {
            return ‘<div class=”col-sm-4″>’ . $content . ‘</div>’;
        }
    endif;
    add_shortcode(‘one_third’, ‘custom_shortcode’);
?>

The added code is in green. The name of the function doesn’t matter because it only gets called by the add_filter call above the function. The ID of this box is summary and when that ID is called, it displays whatever was written in the rwmb_meta(‘summary’) box when the post was written. For instance, the front page of WMTM displays the title, date and summary. Clicking on the article takes you to the article.

            <h3>Latest Wave Theory Post:</h3>
            <?php $my_query = new WP_Query(‘category_name=Wave Theory&posts_per_page=1’);
                while($my_query->have_posts()) : $my_query->the_post();
            $do_not_duplicate = $post->ID; ?>
                <?php the_title( sprintf(‘<h2 class=”entry-title”><a href=”%s” rel=”bookmark”>’, esc_url( get_permalink())), ‘</a></h2>’); ?>
                <?php the_date(); ?>
                <p><?php echo rwmb_meta( ‘summary’ ); ?></p>
            <?php endwhile; ?>

Here is part of the code in my page-home.php. The fields are in green. It’s as simple as that.