I am making a page template that should display custom post-types that have meta value that matches the page title. Meta value is added trough Advanced Custom Field radio buttons, but the query is not taking the meta into consideration, it's displaying all the posts.
I've checked $name
stores the correct string, posts have the correct value for program
key.
Here is the query code:
$name = get_the_title(get_the_ID());
$args = array(
'post_type' => 'project',
'posts_per_page' => -1,
'meta_query' => array(
'key' => 'program',
'value' => $name,
'compare' => 'LIKE'
)
);
$projects_q = new WP_Query($args);
I've even tried to wrap the 'value' value in ""
and change the $name
to lower case but the result is the same.
$name = strtolower(get_the_title(get_the_ID()));
$args = array(
'post_type' => 'project',
'posts_per_page' => -1,
'meta_query' => array(
'key' => 'program',
'value' => '"' . $name . '"',
'compare' => 'LIKE'
)
);
$projects_q = new WP_Query($args);
Is there some special way to query posts with radio buttons?