Support » Fixing WordPress » More link not showing on pageofposts pages

  • Resolved Mark Kehn


    Good evening.

    I am having issues trying to get the <!--more--> link to work on pages that use the pageofposts template and I am at a loss in terms of how to fix it and get it working.

    Here is the Codex page showing the code for the pageofposts template:

    I use two pageofposts pages in my site and the <!--more--> doesn’t work on either of them but it works just fine on the main blog page.

    Here is one of my pageofposts pages:

    It is a page that shows all the categories I use when I make posts about WordPress.

    The first post you see on this page is long and at the heading where it says “So How Many is Too Many” – right before that header is where I have the <!--more--> inserted but as you can see for yourself, it’s not displaying and the post shows in full.

    Can someone troubleshoot this for me? I’d really appreciate it.


Viewing 5 replies - 1 through 5 (of 5 total)
  • stvwlf



    You have to add a few lines of code to include the more functionality in the wp_query code

    See if you can follow this code. I marked the lines to add with “<—- add”

    using the more tag on a page or in the sidebar

    global $more;   <---- add
    $about = new WP_Query();
    $about->query('pagename=about'); // for post use  'name={slug}'
    while ($about->have_posts()) : $about->the_post();
       $more = false; <--- add  // set $more to false to only get the first part of the post ?>
       <p><?php the_content('Read the rest...'); ?></p>
    <?php endwhile;
    $more = true;  <---- add  // restore default $more behavior

    Hey stvwlf,

    Thank you for replying and showing the code to use but your code differs from the code shown in the Codex template I am using, therefore I don’t know how to combine yours with it.

    Here is the top section of code I am using. Just the top portion of it that I think you needed to reference if you wish to help me further.

    Template Name: PageOfPosts
    get_header(); ?>
      <div id="container">
        <div id="content">
          // Page id 53 will get category ID 3 posts, page 55 will get category 10 posts and so on.
          if (is_page('53') ) {
          $cat = array(3,45,46,47,48,49,50,51);
          } elseif ( is_page('55') ) {
          $cat = array(10,40,15,41,42);
          } elseif ( is_page('57') ) {
          $cat = array(43,44);
          } else {
          $cat = '';
          $showposts = -1; // -1 Shows all posts.
          $do_not_show_stickies = 1; // 0 to Show stickies.
             'category__in' => $cat,
             'showposts' => $showposts,
             'caller_get_posts' => $do_not_show_stickies
          $my_query = new WP_Query($args);
          global $more;
          // Set $more to 0 in order to only get the first part of the post.
          $more = 1;
          <?php if( $my_query->have_posts() ) : ?>
            <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
              //necessary to show the tags
              global $wp_query;
              $wp_query->in_the_loop = true;
              <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                <!-- Display the post title in an h2 header. -->
                <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
                <div class="entry-meta">
                </div><!-- .entry-meta -->
                <div class="entry-content">
                  <?php the_content( __( 'Continue reading <span class="meta-nav">&raquo;</span>', 'My-Framework' )  ); ?>
                  <?php wp_link_pages('before=<div class="page-link">' . __( 'Pages:', 'My-Framework' ) . '&after=</div>') ?>
                </div><!-- .entry-content -->

    NOTES: I already had the global $more added since I saw that in another post somewhere but they didn’t show how to use it, so for me – adding it did nothing.

    You show additional code on how to actually use it but I don’t know how to integrate it into my current code. Could you help me some more please?

    The code I added and saw from another post somewhere is:

    global $more;
    // Set $more to 0 in order to only get the first part of the post.
    $more = 1;

    You should be able to find it in the first code block I showed you.

    Much aprpeciated stvwlf.

    Thank you.

    Nevermind stvwlf,

    I got it worked out thank you very much indeed!

    I got it to work using:

    <?php $more = false; ?> before the <?php the_content() ?> line
    <?php endwhile; $more = true; ?> at the end of the loop

    and I went ahead and removed the code I saw from a previous post:

    // Set $more to 0 in order to only get the first part of the post.
    $more = 1;

    I am indeed gratful for your help. It has been bugging me for a long time now not being able to get the <!-- more --> link to work.

    Getting it to work finally will help me a bit with the duplicate content issue we face.

    Thanks again.




    just so you know, in PHP $more = 1 and $more = true mean the identical thing.

    $more = 0 and $more = false mean the identical thing

    glad you got it working

    Huge thanks for this stvwlf – works like a charm 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘More link not showing on pageofposts pages’ is closed to new replies.