Better way to get tag stats?

I addressed a similar problem not long ago – it’s all in the memory: $post_ids = get_posts( array( ‘posts_per_page’ => -1, ‘post_status’ => ‘publish’, ‘fields’ => ‘ids’, // Just grab IDs instead of pulling 1000’s of objects into memory ) ); update_object_term_cache( $post_ids, ‘post’ ); // Cache all the post terms in one query, memory … Read more

What exactly does the ‘s’ parameter search for in WP queries?

As usual it’s most reliable to dump the resulting SQL query and see: SELECT wp_posts.ID FROM wp_posts WHERE 1=1 AND (((wp_posts.post_title LIKE ‘%keyword%’) OR (wp_posts.post_content LIKE ‘%keyword%’))) AND wp_posts.post_type=”post” AND ((wp_posts.post_status=”publish”)) ORDER BY wp_posts.post_date DESC LIMIT 0,5 The only two things native search is considering are title and content.

WP Query to get all posts (including in draft/pending review)

You can add post_status to your query, the string ‘any’ will return all posts no matter the status, or you can use an array to just grab those you want. $args = array( ‘post_type’ => ‘post’, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘post_status’ => ‘any’, ‘posts_per_page’ => 10, ); http://codex.wordpress.org/Class_Reference/WP_Query#Status_Parameters

Tax_query terms ID’s using variable

It looks like you are making an array with a single string inside. Check if making $tax into an array before passing it will work: $tax = array( 19, 18, 214, 226, 20 ); $query_args = array ( ‘post_type’ => ‘works’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘materials’, ‘field’ => ‘term_id’, ‘terms’ => $tax, ) … Read more

How to set posts per page using WP_Query()

query_posts will do the query again (destroy current wp_query and create a new one and then doing the query with the parameters you pass to it) To get the same behaviour after setting the new parameter with set_var you need to query the database again using something like this $wp_query->set(‘posts_per_page’, 1); $wp_query->query($wp_query->query_vars);

query multiple taxonomies

First of all, get all term slugs from the custom taxonomy space by current post ID. $space_terms = wp_get_post_terms( $post->ID, ‘space’ ); if( $space_terms ) { $space_terms = array(); foreach( $space_terms as $term ) { $space_terms[] = $term->slug; } } You should specify the logical relationship between each inner taxonomy array when there is more … Read more

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