I have a head-scratcher! I have a number of different post types, the default post/page/attachment + a handful created with the default CPT UI settings. Just one of them (articles) is misbehaving, with the WP_Query posts_per_page
argument being ignored.
I cannot find anything about reserved post slugs, aside from the usual suspects mentioned above.
So, we have a bunch of post_type=articles. To test, I went into the DB and changed 3 of those to article - removing the s. Though I haven't created the post type in CPT IU, or in functions, WP_Query is able to return it... correctly no less!
$a_articles__featured = array (
'post_type' => 'articles',
'nopaging' => false,
'posts_per_page' => 2,
'update_post_term_cache' => false,
'update_post_meta_cache' => false
);
$q_articles__featured = new WP_Query( $a_articles__featured );
^^^ returns ALL posts with the CPTUI post_type of articles
$a_articles__featured = array (
'post_type' => 'article',
'nopaging' => false,
'posts_per_page' => 2,
'update_post_term_cache' => false,
'update_post_meta_cache' => false
);
$q_articles__featured = new WP_Query( $a_articles__featured );
^^^ returns 2 posts with the manually adjusted post_type of article
$a_articles__featured = array (
'post_type' => 'page',
'nopaging' => false,
'posts_per_page' => 2,
'update_post_term_cache' => false,
'update_post_meta_cache' => false
);
$q_articles__featured = new WP_Query( $a_articles__featured );
^^^ returns 2 posts with the default post_type of page
$a_articles__featured = array (
'post_type' => 'events',
'nopaging' => false,
'posts_per_page' => 2,
'update_post_term_cache' => false,
'update_post_meta_cache' => false
);
$q_articles__featured = new WP_Query( $a_articles__featured );
^^^ returns 2 posts with the CPTUI post_type of events
ALL OF THESE RESULTS ARE REPEATED WITH THE SQL QUERY!
$querystr = "
SELECT $wpdb->posts.*
FROM $wpdb->posts, $wpdb->postmeta
WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
AND $wpdb->posts.post_type = 'articles'
AND $wpdb->posts.post_date < NOW()
ORDER BY $wpdb->posts.post_date DESC
";
$pageposts = $wpdb->get_results($querystr, OBJECT);
Aside from just using article, which is a disruption in the URL, can anyone suggest trouble shooting from here?
Thank you!
wp_reset_postdata();
type of debugging before finding other post types are working.