0

I've searched for days for a solution, scouring the interwebs, including, of course, stackoverflow.

I'm using a custom post type as a static home page, but the pagination will not work. When I attempt to navigate to the second page, it reverts back to the same first page. This is not a problem unless I'm using it as a static front page.

Here's the code I have set up.

<?php $home_num = get_option('of_home_num'); ?>

<?php query_posts( 'post_type=portfolio&posts_per_page='.$home_num.'&paged='.$paged); ?>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

... content ...

<?php endwhile; ?>

<?php else: ?>  

<p><?php _e('Sorry, nothing here.', 'Zoho'); ?></p>

<?php endif; ?>

<?php if (function_exists("pagination")) { pagination($additional_loop->max_num_pages); } ?>

<?php wp_reset_query(); ?>

I know the pagination function works fine, because I've used it many, many times before.

I'm happy to offer a donation to anyone who can help out with this. Like I said, I'm stuck :)

1
  • What's the contents of your pagination function?
    – Chris Cox
    Commented Nov 23, 2011 at 21:46

1 Answer 1

1

Add this to your code, before query_posts line:

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

Should work.

2
  • Didn't seem to work. The same exact code works perfectly if it's not set as a static home page. But if I use it as the home page, pagination doesn't work. It shows that it's on page two in the url, but the pagination doesn't go to page two when clicked. Here's the site themes.siiimple.com/zoho (a theme in development)
    – Justin
    Commented Nov 23, 2011 at 14:49
  • I added the page template that I'm using for the static home page to another page to test if it would work so long as it wasn't being used as the static home page. And it did indeed work. Here's that page themes.siiimple.com/zoho/test-portfolio-page. But as soon as I use this page template (custom post type portfolio) on the static home page it fails to work.
    – Justin
    Commented Nov 23, 2011 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.