Pagination difficulty using custom query in genesis-based custom theme

I am creating a genesis child theme. I have a category called ‘faculty’ with about 60 posts in it. I am modifying the category template file so that it displays this category in a customized fashion.

The desired result is that

Read More
  • the faculty appear in random order,
  • they do not appear more than once
  • they appear in groups of four per page

Here is the relevant code from my page:

remove_action('genesis_loop', 'genesis_do_loop');
add_action('genesis_loop', 'hdo_faculty_loop');

function hdo_faculty_loop() {
  global $paged;
  $args = array(
    'category_name' => 'faculty',
    'posts_per_page' => 4,
    'orderby' => 'rand',
    'paged' => $paged
  );
  genesis_custom_loop(  $args );

}

genesis();

What I am getting is http://hdo.la.utexas.edu/category/faculty/:

  • 4 faculty per page [yay!]
  • random order [yay!]
  • previous and next navigation at the bottom of the page [yay!]
  • only 6 pages (24 faculty) instead of the expected 15 [boo!]
  • duplicate faculty in the set of 24 [boo]
  • a “next” loop on the sixth page that navigates to a 404

Related posts

Leave a Reply

1 comment

  1. I was in the same problem as you, and I found a solution to this matter.
    Go to WP settings, under “reading”, and update the ‘posts_per_page’ value also in there. It’s set to 10 by default.
    I hope it helps!
    Regards.