cache specific data?

This is probably not the most optimal solution, but you could store static metadata as an array in the theme options. The options table is loaded in memory by default, giving you fast access.

Cleanup: best way to remove WooCommerce comments from the wp_comments table

To delete rows in your wp_comments you can use an SQL statement like so DELETE FROM wp_comments where comment_date < ‘2016-01-01’ and comment_type=”order_notes” This will delete all comments older than January 1st 2016. I do believe Woocommerce uses order_notes as a comment_type make sure by checking that column before running the statement. Of course, you … Read more

How to Access wp_usermeta Data Immediately After a New User is Created

The edit_user_created_user will work for when adding users via user-new.php: add_action( ‘edit_user_created_user’, ‘wpse_edit_user_created_user’, 10, 2 ); //for user-new.php page new user addition function wpse_edit_user_created_user( $user_id, $notify ) { $meta = get_user_meta( $user_id, ‘my_field’, true ); } For the sake of completeness, I used the following code for testing the user meta data, which I grabbed … Read more

mySQL statment count of post in each category and sub category

You may try this amateur code. SELECT COUNT(ID) FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (1) ) AND wp_posts.post_type=”post” AND ((wp_posts.post_status=”publish”)) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC Note the term_taxonomy_id IN (1) is where your category ID is 1. You may remove the line for published … Read more