I am looking for a way to perform a search, and while performing the search, it checks a custom field named 'keywords,' the post title, and the post content. If any of those fields have results like what the user searches, it will display the custom post type (programs) in the results page.
I do not need help with the end display result (it currently does what I want it to do), but I need to make it so when it searches it checks all three fields (post title, post content, and custom field keywords), and if any of them have a result like what was searched, it displays the results. This is the code I have so far. It is currently only looking in the keywords custom field:
elseif($program_search) {
// search by program search text
query_posts(array(
'post_type' => 'program',
'meta_query' => array(
array(
'key' => 'keywords',
'value' => $program_search,
'compare' => 'LIKE'
),
)
));
if ( have_posts() ) :
while ( have_posts() ) :
the_post();
$l.= "<div class='program-item'>";
$l.= "<div class='program-item-image'><a href='".get_permalink($post->ID)."'>". get_the_post_thumbnail($post->ID, 'thumbnail')."</a></div>";
$l.= "<div class='program-item-title'><a href='".get_permalink($post->ID)."'>".get_the_title($post->ID)."</a></div>";
$l.= "<div class='program-item-content'>".get_the_excerpt()."</div>";
$l.= "<div style='clear:both;'></div>";
$l.= "</div>";
endwhile;
else:
endif;
}