WP_Query min and max values

Depending on the way your script is recording max_price, it isn’t really a meta_key/meta_value on postmeta table. Did you try changin max_price clause to something like this? [‘max_price’] => [ ‘relation’ => ‘OR’, [ ‘key’ => ‘max_price’, ‘value’ => 11, ‘compare’ => ‘<=’, ], [ ‘key’ => ‘max_price’, ‘compare’ => ‘NOT EXISTS’, ], ],

Overriding The Loop with filter or hook

This seems to work, but I would be interested in hearing from others if it’s the “correct” way to provide this sort of override. I’m assuming you’re visiting a category archive page, like http://www.example.com/category/computers/. // landing page = 188 // category = “computers” (#8) function custom_wpquery( $query ){ // the main query global $wp_the_query; if … Read more

Display recent posts from the same category as current post in sidebar

Try this // Get categories $categories = wp_get_post_terms( get_the_ID(), ‘category’); // Check if there are any categories if( ! empty( $categories ) ) : // Get all posts within current category, but exclude current post $category_posts = new WP_Query( array( ‘cat’ => $categories[0]->term_id, ‘post__not_in’ => array( get_the_ID() ), ) ); // Check if there are … Read more

How to order posts tag by tag?

Like Eugene mentioned in his answer you need to run a query for each tag. I would create a foreach loop that went through each tag then queried the latest 2 posts from each. $tags = get_tags(); foreach ( $tags as $tag ) { echo ‘<h3>’ .$tag->name. ‘</h3>’; $tag_query = new WP_Query( array( ‘tag_id’ => … Read more

WP_Query not looking at child category

You’ll have to get the child or parent categories yourself and pass all the IDs as an array via the category__in argument of WP_Query. You can use get_ancestors to get the top parent category, and get all child categories of that parent via the child_of argument of get_categories.

Build a content and excerpt grid loop with paging and options for # of posts

The $wp_query properties allow “alot” Actually it’s not that hard if you use parts of the $wp_query object like current_post. Here you can see some examples that make some tricky use of things like is_paged(), $wp_query->current_post and $wp_query->posts_per_page. You can switch MarkUp depending on if you’re on the first or later pages, if you got … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)