Support » Fixing WordPress » Possible pagination question

  • Resolved amanojaku2


    Hi everyone,

    I’m using a child of twenty eleven. I have a custom post type called ‘trainer_profile’. It includes, as you may guess, information about personal trainers

    I have a menu item called ‘Personal Trainers’ When selected, it goes to a page-trainer-profile which contains a query that returns the title and permalink to each individual ‘trainer_profile’.

    My question is about what to do when the number of profiles exceeds the ‘posts per page’ figure. Currently I have no idea. Using ‘next_posts_link’ etc I can create next and previous arrows, but they go to archive.php.

    What I want to do is redisplay page-trainer-profile’s styling, with the next 10 profile permalinks displayed.

    I could use php or javascript to create a variable and use that to select what content to display, but I would image wordpress already has some functions that will do the same thing.

    Can anyone advise me on this?


Viewing 9 replies - 1 through 9 (of 9 total)
  • WP should be able to do this. Probably has something to do with your query. Could you show the template files, responsible for displaying the custom post type?

    The query is fairly simple:

    $wp_query = new WP_Query(array( ‘post_type’ => array(‘trainer_profile’)));

    From that there is a bunch of html to display the title and permalink. (I can post it if you like, but I don’t think it is relevant as it is only styling info based on while (have_posts()):the_post; ).

    If I add post_per_page =>10and the nav buttons, only 10 title permalinks display, then the ‘next’ arrow that takes me to archive.php.

    Is posts_per_page, post_per_page or is that just a typo you made here?

    Yep, sorry about that!

    What template file is this code on?


    Pagination always confuses me but

    There is a section on WP_Query pagination parameters
    that mentions a page template and says you need to use an extra parameter in your query:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $query = new WP_Query( array( 'paged' => $paged ) );

    That might be it but I’m not sure at all.

    I’ve been struggling to understand it myself, but thanks for the help! I think the answer is in there somewhere -as it stands, the ‘next page’ link goes still goes to the archive. The more I think about it, the easier it seems just to reload the same page, but pass a variable to it based on whether ‘next’ or ‘previous’ is clicked.

    For anyone reading:

    My problem was resolved with 2 key things- the first as Peter L describes above: using the $paged variable in the loop.

    The second is making sure you page and the cpt have different names. By changing the name of the page (and it’s php file), the problem was resolved.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Possible pagination question’ is closed to new replies.