[resolved] How to show "Newer/Older-entries"-links on a page displaying posts (3 posts)

  1. olesund
    Posted 6 years ago #

    Hi there. Thought I share how to display the next/previous-links (or newer/older-entries) when using a query to display posts on a page.

    Originally I'm using the code at: http://codex.wordpress.org/Pages#A_Page_of_Posts

    to display a certain amount of posts from a certain category on a specific page. To get my pagination working, to get "Newer / Older Entries"-links on the bottom of the page, I add this little snippet to the code:
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    and then
    'paged' => $paged

    This is where you put in the original code:

    $showposts = 10; // -1 shows all posts
    $do_not_show_stickies = 1; // 0 to show stickies
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
       'category__in' => $cat,
       'showposts' => $showposts,
       'caller_get_posts' => $do_not_show_stickies,
       'paged' => $paged
    $my_query = new WP_Query($args); 
  2. khanate
    Posted 6 years ago #


    Im new to php and WP, so could you explain where exactly should I put this code? To the index.php file?


  3. khanate
    Posted 6 years ago #

    Does anyone know the answer to this?

Topic Closed

This topic has been closed to new replies.

About this Topic