meta_query does not filter at all
-
Hi there
I’m trying to filter my pages by two specific page templates since an hour and I cannot figure out why it’s not working.
Here’s my Code:
$args = array( 'meta_query' => array( 'relation' => 'AND', //Optional, defaults to AND array( 'key' => '_wp_page_template', 'value' => array ('page-frontpage.php', 'page-frontpage2.php' ), 'compare' => 'IN' ) ), 'sort_column' => 'post_date', 'sort_order' => 'ASC', ); $frontpages = get_pages($args);
This should in my opinion filter all my pages for the ones with my two different frontpage-templates (1 and 2).
I’m not quite sure aboute the ‘compare’ thing, but I also tried others. The thing is, it dos not have an effect at all.I also tried a different approach, where I repeat my meta_key.
Like this:$args = array( 'meta_query' => array( 'relation' => 'OR', array( 'key' => '_wp_page_template', 'value' => 'page-frontpage.php', 'compare' => '=', ), array( 'key'=>'_wp_page_template', 'value'=> 'page-frontpage2.php', 'compare' => '=', ) ), 'sort_column' => 'post_date', 'sort_order' => 'ASC', ); $frontpages = get_pages($args);
But this did not have an effect either.
I would really be glad if somebody could help me out with this, because I obviously do not see the mistake I’m making…Thanks already for the help
cheers
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘meta_query does not filter at all’ is closed to new replies.