Using WHERE on a WP_Query

If I understood correctly, you need something like the following: $args = array( ‘post_type’ => ‘book’, ‘posts_per_page’ => -1, ‘meta_key’ => ‘subject’, ‘meta_value’ => YOUR_SUBJECT_PAGE_TITLE, ); $books = new WP_Query($args); Is this what you’re trying to achieve? Also, please have a look at WP_Query.

Getting titles from an array of IDs

You can make use of ids in $actor the following way to get the actor’s title. $args = array( ‘post_type’ => ‘actors’, ‘post__in’ => $actors, ); $actors_posts = new WP_Query( $args ); if( $actors_posts->have_posts() ) : while( $actors_posts->have_posts() ) : $actors_posts->the_post(); ?> <h2><?php the_title() ?></h2> <?php endwhile; else: ?> echo ‘Oops, there are no posts.’; … Read more

Get Posts by IDs (optionally)

It looks like WordPress doesn’t ignore empty post__in param. So you’ll have to do this yourself like this… $ids=”1,2,3″; if ( $ids ) { $arr = explode(“,” ,$ids); $args = array( ‘posts_per_page’ => $number, ‘post__in’ => $arr ); } else { $args = array( ‘posts_per_page’ => $number ); }

Using in ‘category_name’ in ‘$query->set();’?

I am unable to duplicate the problem, but the Notice references this line: add_screen_option( ‘per_page’, array( ‘label’ => $title, ‘default’ => 20, ‘option’ => ‘edit_’ . $post_type . ‘_per_page’ ) ); And that makes me think that you should be passing a post type in your GET string. http://wp.dev/wp-admin/edit.php?post_type=post&category_name=intl Just a guess as I can’t … Read more

wp query meta value is not null

Regarding your first problem, because $args is an PHP: array you could do something like this: Code: $args = array( ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘post_type’ => ‘custom_post_type’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => ‘150’ ); if ( $catArr ) { $args[‘tax_query’] = array( array( ‘taxonomy’ => ‘tax_type’, ‘field’ => ‘id’, ‘terms’ => $catArr ) … Read more

tag__in does not return posts

Re: my comment, I am assuming ‘item_tags’ are a custom taxonomy. tag__in only works for WP Core’s Tag taxonomy. Replace your tag__in line with the following: ‘tax_query’ => array( array( ‘taxonomy’ => ‘item_tags’, ‘field’ => ‘id’, ‘terms’ => $tag_ids ) )