Im hoping someone maybe able to point out my mistake. I have a function in functions.php with a simple meta_query.
If I use this query.
$args = array(
'meta_query' => array(
array(
'meta_key' => 'Partner_Level',
'meta_value' => 'Gold',
'post_type' => 'page',
'post_status' => 'publish'
)));
$pages = get_pages($args);
foreach ( $pages as $page ) {
$option = '<option value="' . get_page_link( $page->ID ) . '">';
$option .= $page->post_title;
$option .= '</option>';
echo $option;
}
I retrieve every page in my site, not the ones matching the $args passed to get_pages();
If I simplify the $args to
$args = array(
'meta_key' => 'Partner_Level',
'meta_value' => 'Gold',
'post_type' => 'page',
'post_status' => 'publish'
);
Then Im not getting any results at all.
So it really is an all or none, from what I can see my query looks good, but I know Im overlooking something, but what.... ? Appreciate any help with this.
I have performed a SQL statement and Im able to retrieve the expected results using..
$querydetails = "
SELECT wposts.*
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wpostmeta.meta_key = 'Partner_Level'
AND wpostmeta.meta_value = 'Gold'
AND wposts.post_status = 'publish'
AND wposts.post_type = 'page'
ORDER BY wposts.post_date DESC
";
So my assumption is its something with get_pages() not listening to my $args.
Thanks in advance.
