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

Why is “/page/2/” not working?

Found the answer: After a looong day debugging thru wordpress core, I managed to solve this issue. Basicly, you CANT have a PAGE and a CUSTOM POST TYPE with the same name. If you do, the permalink rewrite rules will get confused and trigger a 404. A very simple solution I’m using is: The page … Read more

Query by post title

You can use either search parameter of wp_query : Code $args = array(“post_type” => “mytype”, “s” => $title); $query = get_posts( $args ); Or you can get posts based on title throught wpdb class: global $wpdb; $myposts = $wpdb->get_results( $wpdb->prepare(“SELECT * FROM $wpdb->posts WHERE post_title LIKE ‘%s'”, ‘%’. $wpdb->esc_like( $title ) .’%’) ); Than you’ll … Read more

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