Forums

The read more functionality with this query doesn't work (5 posts)

  1. CGrrr
    Member
    Posted 2 years ago #

    <?php
    // retrieve one post with an ID of 5
    query_posts('p=5');
    
    global $more;
    // set $more to 0 in order to only get the first part of the post
    $more = 0; 
    
    // the Loop
    while (have_posts()) : the_post();
      // the content of the post
      the_content('Read the full post »');
    endwhile;
    ?>

    The read more functionality with this query doesn't work as i use the code.Is it a bug?

  2. Michael Fields
    Member
    Posted 2 years ago #

    I think that it is a bug, if you don't use query_posts(), then you get the more link but when you do, it returns the full post content. Please try the code below:

    <?php
    $my_post_id = 17;
    $my_post = get_post( &amp;$my_post_id );
    if( $my_post ) {
    	setup_postdata( $my_post );
    	the_content('Read the full post »');
    }
    ?>
  3. CGrrr
    Member
    Posted 2 years ago #

    Wow~Great code!Thank u very much!

  4. Michael Fields
    Member
    Posted 2 years ago #

    No problem!

  5. gmisen
    Member
    Posted 2 years ago #

    hey, i'm having the same problem

    Where exactly do you put this code? in the functions file? or the start of the loop

    and is it much different if my new query is calling all posts in a certain category instead of just one?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags