What I am doing is searching through all my custom post types and all my ACF fields then displaying the link and title to the page where the search term is located. I have on page title that is not included in any of the ACF fields that I am searching, that is how I know my search is not looking at that page titles at all. My code is below any help would be great.
<h2>Search results for: “<?php echo $_GET[‘search’]; ?>”</h2>
<?php
$posttype = get_post_type();
$search = $_GET[‘search’];
$args = array(
‘post_type’ => $paged,
‘posts_per_page’ => ‘-1’,
‘meta_query’ => array(
‘relation’ => ‘OR’,
array(
‘key’ => ‘region-inner-hero-header’,
‘value’ => $search,
‘compare’ => ‘LIKE’,
),
)
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) { ?>
<?php while ( $query->have_posts() ) {
$query->the_post(); ?>
<?php $page = get_the_title(); ?>
<?php } ?>
<?php } else {
echo “Sorry, no results were found here”;
}
wp_reset_postdata();
?>