Last active
April 26, 2019 06:44
-
-
Save harisrozak/60b553e8b29f866f493c4e6289029b34 to your computer and use it in GitHub Desktop.
WordPress::Wp_Query with field ids
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
<?php | |
$args = array( | |
'post_type' => 'custom-post', | |
'posts_per_page' => 10, | |
'post_status' => 'publish', | |
'author' => 1, | |
'fields' => 'ids', | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'custom-tax', | |
'field' => 'name', | |
'terms' => 'new-term', | |
), | |
), | |
); | |
$the_query = new WP_Query($args); | |
$ids = array(); | |
/* result post ids */ | |
if($the_query->have_posts()) { | |
$ids = $the_query->posts; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment