Remove Unnecessary Mysql Query

Best I can tell is that those default widgets get options from the database as their classes are constructed, so there’s no way to prevent the DB queries without disabling those widgets entirely. Depending on your needs, you may want that slight performance bump and do not need the widgets, in which case you can … Read more

Query WordPress database by registered date and role

I’m no SQL expert, but I think it would look something like this: SELECT * FROM mydatabase.wp_users INNER JOIN mydatabase.wp_usermeta ON (wp_users.ID = wp_usermeta.user_id) WHERE 1=1 AND wp_users.user_registered > ‘2014-03-15 00:00:00’ AND wp_users.user_registered < ‘2014-03-16 00:00:00’ AND ( (wp_usermeta.meta_key = ‘wp_capabilities’ AND CAST(wp_usermeta.meta_value AS CHAR) LIKE ‘%\”subscriber\”%’) ) ORDER BY user_registered ASC ;

Custom query to get terms from post ids

It is not advised to make use of custom SQL queries if there are functions in WordPress that already does the job. To accomplish this, you can simply make use of wp_get_object_terms(). The first parameter $object_ids takes a string or an array of object ID’s. In your case, you can make use of an array … Read more

Difference between fragment caching and wp_cache

I’ll post this as an answer, even though I don’t know much about caching. If you read about WP Object Cache it says: By default, the object cache is non-persistent. This means that data stored in the cache resides in memory only and only for the duration of the request. Cached data will not be … Read more

Use two WP Query in template

Yes, you can use two instances of WP_Query as long as you call the wp_reset_postdata function, just like you did in your code. You’re missing the while statement and posts_per_page for WP_Query array argument item. <?php $query = new WP_Query( array( ‘post_type’ => ‘item_a’, ‘posts_per_page’ => -1 /** Show all **/ ) ); if ( … Read more