• I am currently trying to add pagination ex.(Prev,1,2,3,4,5,Next) to a custom post type I created. After troubleshooting for a few hours I cannot figure out what is going on. Any help would be much appreciated!

    Here is a link to pastebin of my loop.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Take a look at the WP PageNavi plugin.

    Not sure if you are having trouble with paging or you want to know about the plugins?

    If you are having trouble with paging then try and remove:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

    Plugins:
    If you want page-navi or wp-navigate plugins then this post might help you locate the code.

    HTH

    David

    @david, look at the pastebin – $paged is set and in the query parameters.

    Hi vtxzzy,
    I would remove the line, it is not needed, as 'paged' => $paged, tells WordPress to return the $paged variable, so as you navigate through the pages WordPress sets the value, I never use the line and it works ‘out the box’ for my queries.

    If we look at the Codex

    Pagination Note: You should set get_query_var( ‘page’ ); if you want your query to work with pagination. Since WordPress 3.0.2, you do get_query_var( ‘page’ ) instead of get_query_var( ‘paged’ ). The pagination parameter ‘paged’ for WP_Query() remains the same.

    I just use:

    'paged'=> $paged,

    Which is like:

    'paged'=> get_query_var( 'page' ),

    Regards

    David

    Thread Starter occams_laser

    (@occams_laser)

    Hey guys,

    Thanks for the responses! I managed to fix my problem by using the WP PageNavi plugin. I thought WordPress had default paging features in the core files.

    I have another question for you guys, how would I go about having a “View All” link next to the pagination which would display all related posts on the page? Thanks again for the responses!

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

The topic ‘Adding Pagination to Custom Post Type’ is closed to new replies.