I have multiple custom post types and I need to be able to query them and page through them. This is the query I am trying:
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$offset = ( 10 * $paged ) - 10;
$args=array('paged'=>$paged, 'posts_per_page'=>10, 'post_type'=>'custom-post-type-name', 'offset' => $offset);
query_posts($args);
I’ve reset the permalinks and I’ve set the posts per page of WordPress to a lower number than what I’m querying and all I get is a 404 when I go to /page/2/ (my permalinks are set as /%postname%-%post_id%
).
What’s most confusing though is on a separate page the following works:
SELECT *, IFNULL(SUM(vote),0) as total FROM wp_posts post LEFT JOIN wp_wdpv_post_votes votes ON votes.post_id = post.ID WHERE post.post_type="custom-post-type-name" AND post.post_status="publish" AND post.post_date > DATE_SUB(NOW(), INTERVAL 1 DAY) GROUP BY post.ID ORDER BY total DESC LIMIT 0,3
but the following throws up the same 404 problems
SELECT *, IFNULL(SUM(vote),0) as total FROM wp_terms term JOIN wp_term_taxonomy taxonomy JOIN wp_term_relationships relationship JOIN wp_posts post LEFT JOIN wp_wdpv_post_votes votes ON votes.post_id = post.ID WHERE term.term_id = taxonomy.term_id AND relationship.term_taxonomy_id = taxonomy.term_taxonomy_id AND term.slug = 'games' AND taxonomy.taxonomy = 'category' AND post.ID = relationship.object_id AND post.post_type="custom-post-type-name" AND post.post_status="publish" AND post.post_date > DATE_SUB(NOW(), INTERVAL 1 DAY) GROUP BY post.ID ORDER BY total DESC LIMIT 0,3
Any help on this would be gratefully received.