Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Head is getting melted with this pagination crap in WordPress!

What am I doing wrong here…

Test site

http://www.clients.eirestudio.net/savvas/reviews/

Code

<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("post_type=bingo_review&posts_per_page=1&paged=$paged");
if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
   blah
<?php endwhile; ?>      
<?php endif; ?>

<?php wp_paginate(); ?>
share|improve this question
    
Can you provide your code for the $paged function from your functions.php file? ALso, do you have enough posts created to require pagination? –  Jeremy Jared Nov 12 '11 at 13:27
    
Hi Jeremy, the wp_paginate function is just a plugin, I could have used previous_posts_link etc but the problem remains. Yes, I have 2 posts and set them to display 1 per page. I'm stumped. I remeber WordPress was easier to work with pagination before adding CPTs... –  Keith Donegan Nov 12 '11 at 13:53
    
Oh wait, how do you mean the $paged function. This is just a variable –  Keith Donegan Nov 12 '11 at 13:55
    
Yes you're correct it is just a variable, I should have referred to it as such. Regards, –  Jeremy Jared Nov 12 '11 at 15:54

1 Answer 1

this is more of a suggestion than an answer. I'm not an expert on custom post type pagination, or custom post types, but I've spent quite a bit of time testing different methods. I've found one that works pretty good and doesn't require a plugin. I still keep up with this subject on various websites, but for now this is working for me. If your interested here is the link to the source:

Custom Post Type Pagination Chaining Method

REVISION:

If you don't want to mess with the method above I have a possible solution that is closer to what you're currently using. Here is my version of the code you posted:

<?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; ?>
<?php $offset = ( 1 * $paged ) - 1; ?>
<?php $args=array(
  'paged'=>$paged, 
  'posts_per_page'=>1, 
  'post_type'=>'bingo_review', 
  'offset' => $offset); 
  ?>
<?php query_posts($args); ?>
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
   blah
<?php endwhile; ?>      
<?php endif; ?>
<?php wp_paginate(); ?>

Give that a try and let me know how it turns out.

share|improve this answer
    
Thanks again Jeremy but unfortunately no luck. Why do the WP developers make it so hard to do something that should be so easy! –  Keith Donegan Nov 12 '11 at 16:20
    
I'm sure that wasn't the intent. It works well for lot's of others, so at least part of the issue is caused by lack of knowledge on the developers part. If you stop and think about it, WordPress has done amazing things to allow people that know nothing about web development to create their own sites. It's easy to overlook that, but you should put things in perspective. If something is beyond your ability you should consider hiring a developer to do it for you. –  Jeremy Jared Nov 12 '11 at 16:32
    
Jeremy, I have been developing with WP for a few years now, made countless sites using it and consider myself pretty knowledgeable with it. If you search the forums or google you will see alot of people have similar issues with CPTS and pagination. My point was, WordPress is known for being easy to use/develop for, but this pagination with CPTS seems to effect alot of people... Also the link you gave to the chaining method does not exactly follow WordPress's 'easy to use' goals. –  Keith Donegan Nov 13 '11 at 17:32
    
I thought it was pretty simple myself. The author has give clear instructions, the only thing you need to do is change the post_type to match your specific need and upload the files into the correct directory. Open the functions.php file that is provided with the download and paste it into your functions.php file. Sorry if I offended you, I just think people need to realize that keeping things simple yet allow users to customize it to fit their specific needs isn't easy. I think WP has done a good job given the amount of options available. –  Jeremy Jared Nov 13 '11 at 18:41
    
Also keep in mind that WordPress is open source, and most the developers don't even get paid. Maybe you could contribute and help make it better. –  Jeremy Jared Nov 13 '11 at 18:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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