• Resolved Sam_Tutt

    (@sam_tutt)


    Hi

    I have been trying to get this to work for a while now but everything i have tried seems to not work 100%. Currently i have the first 5 post titles displaying and then i have a show more button set up to display the next 5.

    The code i am using for the first 5 is:

    <?php
    $current_author = get_query_var('author');
    $author_posts=  get_posts( 'author=2&posts_per_page=5' );
    if($author_posts){
    echo '<ul class="author-articles">';
    foreach ($author_posts as $author_post)  {
     echo '
    <li><a>ID).'">'.$author_post->post_title . mysql2date('j M Y', $post->post_date);'</a>  </li>
    ';
    }
    echo '';
    }
    ?>

    And then to try and get the 6th to 10th post i have tried to change
    $author_posts= get_posts( ‘author=2&posts_per_page=5’ );

    to

    $author_posts= query_posts('author=2&showposts=10&offset=6');

    But it will generate the titles and then display the content of each post as well which i dont want

    Any help is appreciated

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code has now been damaged by the forum’s parser.]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi,

    I had a similar situation some time back and I found the link below really helpful:

    https://wordpress.stackexchange.com/questions/11578/custom-page-links-for-paginated-posts-wp-link-pages-nextpage-quicktag/11588#11588

    See if that solves the problem.

    Thread Starter Sam_Tutt

    (@sam_tutt)

    Hi tsure,

    Thanks for the help but doesn’t look like what I need

    @sam_tutt So you want only the link for the next 5 posts. ?

    Thread Starter Sam_Tutt

    (@sam_tutt)

    Dont worry i solved the problem

    In the second lot of code i had query_post instead of get post

    My code now looks like this:

    <?php
    $current_author = get_query_var('author');
    $author_posts=  get_posts( 'author=2&posts_per_page=5' );
    if($author_posts){
    echo '<ul class="author-articles">';
    foreach ($author_posts as $author_post)  {
     echo '<li><a href="'.get_permalink($author_post->ID).'">'.$author_post->post_title . mysql2date('j M Y', $post->post_date);'</a>  </li>';
    }
    echo '</ul>';
    }
    ?>
    
    <div>
    Show More
    </div>
    
    <div>
    <?php
    $current_author = get_query_var('author');
    $author_posts=  get_posts('author=2&posts=10&offset=6');
    if($author_posts){
    echo '<ul class="author-articles">';
    foreach ($author_posts as $author_post)  {
     echo '<li><a href="'.get_permalink($author_post->ID).'">'.$author_post->post_title . mysql2date('j M Y', $post->post_date);'</a>  </li>';
    }
    echo '</ul>';
    }
    ?>

    I have got it to work where you click the show more button and shows the other 5 posts!

    Thanks for all of your help!

    Awesome ! Thanks for sharing.
    If your specific question has been answered, we would love it if you would mark this topic as resolved in the right hand sidebar. This helps our volunteers find the topics that still need attention and more people will get helped, possibly like you did.

    If you have another question you can always ask us again on this forum.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Get the post titles and links for post 6 to 10’ is closed to new replies.