Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress

Simon Tucker
Simon Tucker
9,113 Points

My pagination works fine on my blog but doesn't show up on custom post types.

I have a pagination function set-up in functions.php I then target the name in my home.php and the pagination displays fine, however the pagination doesn't show up at all on my custom post types. I have followed the same steps for the blog but nothing. Any ideas?? Cheers.

2 Answers

Simon Tucker
Simon Tucker
9,113 Points

Cracked it. my query was different instead of wp_query it was just query. This bit of code also helped display my required custom posts.

<?php $args = array(
    'post_type' => 'bond' 
  );

    $wp_query = new WP_Query( $args );

      $wp_query->query('showposts=2&post_type=bond'.'&paged='.$paged);
?>

<?php wpex_pagination(); ?> /*this code is in my functions.php */
Andi Wilkinson
Andi Wilkinson
26,822 Points

I had a real problem with this when i built my first WordPress site - but i got round it by using archive-$cpt-name.php as the page template & it worked fine. - let me know if you need any further clarification?

Simon Tucker
Simon Tucker
9,113 Points

Hi, I tried but still not working. Do you have an example? I might be coding it wrong.