Here is the way to query custom post_types in WordPress 3.0 and allow paging of the results….
Throw this is a custom page template and sit back and enjoy…
//The Query
<?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; ?>
// current page times the amount you want to show per page -chapeau Justin Tadlock
<?php $offset = ( 5 * $paged ) - 5; ?>
<?php $args=array(‘paged’=>$paged, 'posts_per_page'=>5, 'post_type'=>'you_custom_post_type', 'offset' => $offset); ?>
<?php query_posts($args); ?>
//The Loop
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
//what you want to display from the query… excerpt images etc..
<?php endwhile;?>
//your navigation links
<?php endif; ?>





I have spent weeks trying to figure this thing out and I was wondering if it was a WP 3.0 thing. Now I tried your code and it SOMEHOW didn’t work. I am at a complete loss. I am seeing snippets of this similar code all over the net but can’t figure out why it won’t work on my site, http:/chooseavirb.com/bicl2
I checked your site and couldn’t access the content
“You need to be logged in! “
[...] solución definitiva la encontré gracias a los chicos de The Boring Group. Por el camino quedaron muchas otras, entre ellas un hilo de los foros oficiales de WordPress que [...]
Thanks for the code though we had a few issues with it. Here is our finished version for regular posts:
$showposts = 10; $offset = 5; $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $offset = ( ( $showposts * $paged ) - $showposts ) + $offset; query_posts('offset='.$offset.'&showposts='.$showposts.'&paged='.$paged);Seems good, pleased that it help you in the right direction.
Just tested my original code and still working, you got me worried then…
Thank you so much! After hours of struggle this was the query that worked!!
Jeroen´s last blog ..De gevolgen van de digitale revolutie
thanks for code, but i have this query:
$querystr = “SELECT * FROM {$wpdb->prefix}posts
INNER JOIN tb_oferta_cidade m2 ON ( wp_posts.ID = m2.id_oferta)
WHERE wp_posts.post_type = ‘oferta’ AND wp_posts.post_status = ‘publish’
AND m2.id_cidade IN (“.$_COOKIE["id_cidade"].”) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC;”;
it really works, but I dont know how to page that! i dont whant use post_meta because nesse some strutcture better than only strings.
can you help me?
Can I have your full loop and template I will see what I can do for you…
it’s very helpful.
Thanks for all the help provided in the blog
Number of plugins can be found for paging. No worries.:)
'post_type'=>'you_custom_post_type'is just what i was looking for.
<?php // set the $paged variable $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // query the posts of your custom post types query_posts( array( 'post_type' => array( 'post', 'post_with_slideshow' ), 'paged' => $paged ) // for paging links to work ); ?>…that’s how I was able to query posts to include more than one post_type.
Thanks!