posts_per_page not working in block

The problem was that there were ‘pinned’ posts, which were overriding everything. Un-pinning these posts seemed to do the trick. Also, thanks to Sally CJ for the nopaging tip – I wasn’t aware that it causes posts_per_page to be ignored also.

WP_Query() not filtering posts for category

the_post() operates on the main query, but this isn’t the main query you’re looping over, you need to use $q->the_post() Remember: the_post() is the same as global $wp_query; $wp_query->the_post(); All post loops are WP_Query post loops if you dig down deep enough, even get_posts has a WP_Query inside it There can only be 1 current … Read more

Search results for ACF data

This worked for me: <?php if($_GET[‘module_search’] && !empty($_GET[‘module_search’])) $keywords = $_GET[‘module_search’]; ?> <!– Set args for search of cpt –> <?php $args = array( ‘post_type’ => ‘lectures’, ‘order’ => ‘ASC’, ‘posts_per_page’ => -1, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘keywords’, // name of custom field ‘value’ => ‘[[:<:]]’.$keywords.'[[:>:]]’, // matches exaclty “123”, … Read more