wp query get ids

Solutions on MaxInterview for wp query get ids by the best coders in the world

showing results for - "wp query get ids"
Eric
24 Aug 2017
1/**
2 * Return an array of post IDs
3 *
4 * Build a more efficient query by only returning an array of post IDs.
5 *
6 * @author David Egan
7 * @return array Array of post IDs
8 * @see http://codex.wordpress.org/Class_Reference/WP_Query#Return_Fields_Parameter
9 */
10function carawebs_student_questionnaire_results(){
11
12  $args = array(
13    'post_type'     => 'questionnaire-result',
14    'post_status'   => 'publish',
15    'fields'        => 'ids',
16    'meta_query'    => array(
17      array(
18        'key'        => 'user_type',
19        'value'      => 'student',
20        'compare'    => '=',
21        'type'       => 'CHAR',
22      ),
23    ),
24  );
25
26  // The Query
27  $result_query = new WP_Query( $args );
28
29  $ID_array = $result_query->posts;
30
31  // Restore original Post Data
32  wp_reset_postdata();
33
34  return $ID_array;
35
36}
queries leading to this page
get all posts id from new wp querynew wp query based on idswp have posts specify ids to returnwp query return idswp query get idwp query by idswp term get idwp query by idwp query ids inwp term object get idwp insert get idwp query get only idswordpress get only posts from id listhow to get id in wpwordpress wp term get idwordpress wp query return idswp query by idswp get idwordpress get ids from querywp get current queried idwp query name return idget id in wp queryget id where query in wordpresswp query for find posts by current idwp query term idswp query get all idswp query du post idwordpress query list of post idswp query fields ids foreachfield id in wordpress querywp user query get only specific by idget id where query woe in wordpresswordpress where ids inwp query where ids inget the id wpquery id field wordpressget only the post with a array of ids wordpress qp querywp query by idwp have posts specify ids to returnwp query fields idswp query get idswp query get idget wp query categories idwp quewry only post idswp query get idsquery posts page idswp get the idwp query specific idswp function get idwp query idsget id wptax query term idwp query where idsget posts data by posts id in wp querywp query idwp query only idswordpress wp query get only idswp get term by idwp query idsquery get posts idswp query id inget only post id wp querywp query ids onlywp query post id data fetchget id from name wphow to get only ids for wp querywp query get only ids and namewp while have posts specify ids to returnwp query get by idshow to get the post ids from a wp querywp query get ids