Article written by Boring-Group

I am a Sound Engineer turned entrepreneur. CEO of Boring Group Ltd. I am what could be called a cinemaphile crossed with a audiophile.

12 responses to “WordPress query_posts with custom post_types and paged results -solved”

  1. Dwaynne

    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:/

  2. » Blog Archive » Cómo conseguir un loop con offset y paginación

    [...] 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 [...]

  3. Tim

    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);

  4. Jeroen

    Thank you so much! After hours of struggle this was the query that worked!!
    Jeroen´s last blog ..De gevolgen van de digitale revolutieMy ComLuv Profile

  5. carlos

    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?

  6. sandeep

    it’s very helpful.

    Thanks for all the help provided in the blog

  7. Anil

    Number of plugins can be found for paging. No worries.:)

  8. Zach


    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.


Leave a Reply to Boring-Group Click here to cancel reply.

CommentLuv Enabled