Articles of wp query

Merging a complex query with post_rewind and splitting posts into two columns

I need help with my query that uses rewind_posts so that if a post is in a particular category, it moves to the top. What I would like to do is have a query that splits posts into a two-column page (left and right divs) and if a post is in a category called First, […]

postsperpage value not being applied

I have a custom post type called laptop, and in my theme’s front-page.php I have: $loop = new WP_Query( array( ‘post_type’ => ‘laptop’, ‘postsperpage’ => ’30’ ) ); if ( $loop->have_posts() ) { ?> <!– display laptops –> However, only 10 laptops are displayed. I find that in Settings > Reading > Blog pages show […]

WP_Query with one category in args shows other categories

I want to list titles of the default WP posts of “blog” category in my blog page, which has “Blog” title and uses page-blog.php as template with the following code in it: <article> <?php $args = array ( ‘post_type’ => ‘post’, ‘category_name’ => ‘blog’ ); $query = new WP_Query( $args ); if ( $query->have_posts() ) […]

find posts that don't have a custom taxonomy

I am using a custom taxonomy series to keep track of posts that are in a series. I would like to find the posts that do not have a series. I have the following query: global $wpdb; $pr = $wpdb->prefix; $sql_no_series= “Select * from wp_term_taxonomy tt, wp_term_relationships tr, wp_posts p WHERE tt.term_taxonomy_id=tr.term_taxonomy_id AND tr.object_id=p.ID AND […]

WP_Query with multiple orderby NOT working with ASC and DESC, what's wrong?

I have a query with multiple orderby params in a custom page that I am having difficulty getting to work. The query is to return posts with either tag-AAA or tag-BBB tags. And I’d like to sort it based on DESC order by post_date but within the same pub day sort by post title in […]

How to make Meta Query case sensitive?

I have a meta query similar to: $posts = new WP_Query( ‘post_type=article&meta_key=kln_aid&meta_value=’ . $aid ); where I need aid to be case-sensitive. Is that possible via Meta Query?

Can I simplify in function column_default use of queries

In below function column_default I have several cases doing almost the same query. Is it possible to use only 1 query for all the 3 cases? And if so how do I use it in below example? Thanks for helping me. function column_default($item, $column_name){ global $wpdb; /* if ( ! in_array( $column_name, [‘id’, ‘user_id’, ‘user_email’, […]

Only Get A Certain Number of Posts From WP_Query

I’m not sure what I’m doing wrong. None of my WP_Queries are returning the given number of posts. From what I can tell, it’s returning all of them. How do I fix this? Here is the code I’m currently using for my loops: <?php wp_reset_query(); ?> <?php $review = new WP_Query(array( “posts_per_page” => 1, “category_name” […]

How to exclude a category name from showing?

So I’m trying this code: <?php global $post; $my_query = new WP_Query(‘showposts=8&category_name=featured’); while ($my_query->have_posts()): $my_query->the_post(); $do_not_duplicate = $post->ID; $category = get_the_category(); $content = get_the_content(); $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID) , ‘main-thumbs’); $tn_id = get_post_thumbnail_id($post->ID); $img = wp_get_attachment_image_src($tn_id, ‘main-thumbs’); $width = $img[1]; $height = $img[2]; ?> …. <div class=”cat-square <?php echo esc_html($category[0]->slug) ?>”> with this, I can style […]

Wp_query with 2 meta keys and array of meta values

Hi in my post_type=shop i have 2 meta keys and array of values Custom fields Name Values cu_status pending,processing,completed cu_date 12-Jan-2016 , 13-Jan-2016, …… any date in the same format date(“d-M-Y”) Now i need to loop through all posts with cu_status =pending,processing and cu_date is between 12-Jan-2016 to 13-Apr-2016 What will the query ? Iam […]