New answers tagged query-posts
Use the fields argument in your query. fields (string) - Which fields to return. All fields are returned by default. There are two other options: - 'ids' - Return an array of post IDs. - 'id=>parent' - Return an associative array [ parent => ID, … ]. http://codex.wordpress.org/Class_Reference/WP_Query#Return_Fields_Parameter $latest = new ...
Try $post_ids = wp_list_pluck( $latest->posts, 'ID' ); Read wp_list_pluck
To include custom post time in the $author_query array, add another key=>value element to $author_query array. Example: $author_query = array( 'posts_per_page' => '-1', 'author' => $current_user->ID, 'post_type'=>'your custom post type name' );
Yep, it's not very common, but perfectly viable and nifty technique. After the posts are retrieved in WP_Query they are passed through the_posts filter like this (where $this is WP_Query instance): $this->posts = apply_filters_ref_array( 'the_posts', array( $this->posts, &$this ) ); You just loop through array and assign the extra data you need ...
Hmm... Try altering your query a little to: $args = array( 'post_parent' => $post_id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID', ); $attachment = new WP_Query( $args ); $attachment = $attachment->posts; Alternatively, ...
Before I fire away, just one note, NEVER (my emphasis) make use of query_posts to create custom queries Note: This function isn't meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic way to modify main query of a page by replacing ...
You need to query by the meta_key instead of meta_value: $query_string . '&meta_key=name_of_key_that_stores_free_or_pro&orderby=meta_value_num'
number_posts is not a valid parameter, it should be numberposts. You should also just use either numberposts or posts_per_page You should also include a check (!is_admin()) in your query to check whether you are on the front end or back end as pre_get_posts alters back end queries as well Rewrite your code to the following: function ...
Top 50 recent answers are included