not functioning

I see several things that may be contributing to your issue.

First, you’re using a custom page template to display the blog posts index, instead of using home.php as specified by the Template Hierarchy. That might be a problem, because the <!--more--> tag doesn’t work on singular pages, and since you’re doing funky things with the default query (more on that below), The global $more on which <!--more--> relies might not be getting set as you expect it to be.

Proper configuration of static page as blog posts index

So, the first step is to set up a proper configuration for a static page as blog posts index:

  1. Ensure your chosen static page is selected as Posts Page in Dashboard -> Settings -> Reading
  2. Rename your custom page template as home.php
  3. Remove the Template Name: Blog Template tag from the phpDoc header
  4. (Assumed: you have a static page already selected as Front Page)

Don’t stomp on the main query

If that alone doesn’t resolve your problem, then the next issue to investigate is the way you’re stomping on the default query with query_posts(). Do not ever use query_posts(), for anything, ever.

If you want to set your blog posts index to display a given number of posts, then filter the $query via pre_get_posts, like so:

function wpse76634_filter_pre_get_posts( $query ) {
    if ( is_home() && $query->is_main_query() ) {
        $query->set( 'posts_per_page', '5' );
    }
}
add_action( 'pre_get_posts', 'wpse76634_filter_pre_get_posts' );

Then, get rid of your call to query_posts() in the template file.

Proper usage of <!--more-->

If that doesn’t resolve your problem, then the next step is to check your usage of the <!--more--> tag itself.

Ensure that the tag is exactly <!--more-->, with no spaces between <!-- and more or between more and -->.

Issues Outside the Template

If that still doesn’t resolve your problem, you may have code somewhere, either in functions.php or in a Plugin, that is altering the functionality of the <!--more--> tag.

To test for a Plugin-related issue, deactivate all Plugins, and switch to the default Theme (currently: Twenty Twelve) and verify whether the <!--more--> tag works properly. If it then works properly, re-enable your Plugins one-by-one. If the <!--more--> tag still works properly with all Plugins active, then the problem is somewhere in your Theme.

The next step is to rule out your template file. If you’ve followed the steps above, rename home.php as home.php.old, so that WordPress falls back to index.php to render the Blog Posts Index. Then, verify whether the <!--more--> tag works properly.

If it does, then the problem is your template. If it doesn’t, then the problem is somewhere in functions.php.

Leave a Comment