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

Display/Filter post using if else statement

The PHP while command doesn’t work like that, it needs to start and end in the same code block. You can’t start it inside one if then end it somewhere else (although that would be nice!) What you can do is test have_posts before you start the while loop, and then keep which ever query … Read more