why ignore_sticky_posts in sticky post query

We all know that ignore_sticky_posts is used to exclude sticky post from your custom query. – No, this assumption is wrong. What ignore_sticky_posts means: Even though in natural English, ignore_sticky_posts sounds like WordPress should ignore all sticky posts from the query, in reality that is not what WordPress does. Instead, you should read ‘ignore_sticky_posts’ => … Read more

Posts with at least 3 tags of a list of tags

The answer below is simplified, and could be extended to check if any posts have 3 matching tags before outputting the list. Using one query and assuming you have at least one post with 3 matching tags: //List of tag slugs $tags = array(‘foo’, ‘bar’, ‘chocolate’, ‘mango’, ‘hammock’, ‘leaf’); $args = array( ‘tag_slug__in’ => $tags … Read more

How to merge two queries together

A single query Thought about this a bit more and there’s a chance that you can go with a single/the main query. Or in other words: No need for two additional queries when you can work with the default one. And in case you can’t work with a default one, you won’t need more than … Read more

Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?

The Problem I think there’s a typo in there: The name of the filter is posts_fields not post_fields. That could explain why the title2 field is unknown, because it’s definition isn’t added to the generated SQL string. Alternative – Single filter We can rewrite it to use only a single filter: add_filter( ‘posts_orderby’, function( $orderby, … Read more

What is appropriate flow for custom data from URL in WP_Query?

I think the WP function you are looking for is add_rewrite_tag. It aims to add custom GET params to your URL and include it automatically in query_vars. For example, you can add the following to the init hook : add_rewrite_tag(‘%person%’,'([^&]+)’); For a url like http://example.com?person=joe, the global $wp_query will have $wp_query->query_vars[‘person’] = ‘joe’ You can … Read more

Query posts only with featured image

When running the importer, you must check the checkbox to download and import all media/attachments. If you do not, the posts will still have a featured image set, but the attachment they refer to will be invalid, and any attempt to call the_post_thumbnail will fail. Using your code you would get just the post title, … Read more

meta_query ‘compare’ => ‘IN’ not working

There’s no easy way to search serialized values in a meta query. If the list of values isn’t crazy long, potentially you could set up multiple meta queries: ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘system_power_supply’, ‘value’ => ‘single’, ‘compare’ => ‘LIKE’, ), array( ‘key’ => ‘system_power_supply’, ‘value’ => ‘redundant’, ‘compare’ => ‘LIKE’, … Read more

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