Created
June 28, 2017 07:18
-
-
Save qwersk/038c755bdf0efdbc72c924a43d9ebb0d to your computer and use it in GitHub Desktop.
QUERY BY ACF FIELD #WORDPRESS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function my_posts_where( $where ) { | |
$where = str_replace("meta_key = 'document_%", "meta_key LIKE 'document_%", $where); | |
return $where; | |
} | |
add_filter('posts_where', 'my_posts_where'); | |
$args = array( | |
'numberposts' => -1, | |
'post_type' => 'course', | |
'meta_query' => array( | |
'relation' => 'AND', | |
array( | |
'key' => 'document_%_type', | |
'value' => $document, | |
'compare' => 'IN' | |
), | |
array( | |
'key' => 'form_of_edu', | |
'value' => $form_of_edu, | |
'compare' => 'IN' | |
), | |
array( | |
'key' => 'type', | |
'value' => $type, | |
'compare' => 'IN' | |
) | |
) | |
); | |
$query = new WP_Query( $args ); | |
$arr = $query->posts; | |
print_r($arr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment