Support » Fixing WordPress » Pagination on page that display posts

  • Hello.
    I’ve run in to a problem when trying to show posts from a specific category on a page.

    I have a page on my site where I, apart from showing the page content want to show news that I post via “posts” in the admin panel, under category “news”. I also want to be able to have a “Read more”-link and a pagination for showing only 6 posts per page.

    Can anyone tell me which approach I should use for this? I’ve used the concept of using ajax and php files, but that approach was to far-fetched, and I want to do the “WordPress” way.


Viewing 1 replies (of 1 total)
  • If the ‘news’ category posts do not belong to other categories, you can alter single.php to test for the category and use the ‘true’ parameter to previous/next_post_link like this (replace 44 with your category id):

    <div class="navigation">
            <?php if ( in_category('44') ) { ?>
               <div class="alignleft"><?php previous_post_link('&laquo; %link','%title',true) ?></div>
               <div class="alignright"><?php next_post_link('%link &raquo;','%title',true) ?></div>
             <?php } else { ?>
                <div class="alignleft"><?php previous_post_link('&laquo; %link') ?></div>
                <div class="alignright"><?php next_post_link('%link &raquo;') ?></div>
             <?php } ?>

    The drawback to this approach is that it will cause that category to always stay in category, even when selected from a date archive or blog page. The alternative is much more complex to implement because it involves adding a new parameter to all links in the archive and blog templates and checking for it in single.php.

Viewing 1 replies (of 1 total)
  • The topic ‘Pagination on page that display posts’ is closed to new replies.