How to query posts of standard post format. For real

It looks like your syntax is a little off for the tax query. Try this: $query = new WP_Query( array( ‘post_type’ => ‘post’, ‘cat’ => ‘-1’, ‘posts_per_page’ => 2, ‘tax_query’ => array( array( ‘taxonomy’ => ‘post_format’, ‘field’ => ‘slug’, ‘terms’ => array(‘post-format-aside’, ‘post-format-gallery’, ‘post-format-link’, ‘post-format-image’, ‘post-format-quote’, ‘post-format-status’, ‘post-format-audio’, ‘post-format-chat’, ‘post-format-video’), ‘operator’ => ‘NOT IN’ ) … Read more

How do I exclude all images from a wp_query?

Pretty much the solution is to include all mimes except images. WordPress has a nifty little function where it keeps all it’s accepted mime-types called get_allowed_mime_types() ( cleverly named ) which returns an Array() of mimes. All we need to do is get the difference between the returned array and the array of mime-types we … Read more

Extending WP_Query — Optimise SQL query

Here’s an idea, however it will require the ability to make custom SQL queries – with $wpdb. Since you want to get posts followed by a user, you can create a view, with the following structure: id user_id post_id post_title post_content … (all other post fields) don’t worry about duplicating posts. When you select, you … Read more

Slow SQL_CALC_FOUND_ROWS Query

The use of SQL_CALC_FOUND_ROWS is not really a problem, although it incurs an overhead. What happens is, WordPress uses SQL_CALC_FOUND_ROWS in order to determine the total posts that would have been returned, if no LIMIT clause was provided. This is necessary in order to calculate and provide you with correct pagination links. Disabling it unconditionally … Read more

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