Woocommerce: Grab total revenue of a product over all orders

Got it solved. Probably not the most efficient way but it works! SELECT product_id, meta_value FROM ( SELECT order_meta.order_item_id, order_meta.meta_value AS ‘product_id’ FROM wp_woocommerce_order_itemmeta AS order_meta LEFT JOIN wp_woocommerce_order_items AS order_items ON order_meta.order_item_id = order_items.order_item_id LEFT JOIN wp_term_relationships AS term_rels ON term_rels.object_id = order_items.order_id WHERE term_taxonomy_id = 24 AND order_meta.meta_key = ‘_product_id’ ) AS product_ID … Read more

How to remove calendar widget?

It’s easy to remove a default widget from WordPress. Just add this to your functions.php file: function remove_calendar_widget() { unregister_widget(‘WP_Widget_Calendar’); } add_action( ‘widgets_init’, ‘remove_calendar_widget’ ); See more here: http://codex.wordpress.org/Function_Reference/unregister_widget

unused post IDs

You can stop WP creating revisions by adding the following to your wp-config.php: define(‘WP_POST_REVISIONS’, false ); You can replace false with an integer if you just want to restrict the number a maximum number of revisions. If you check the plugin directory you’ll find several that will clean up old revisions, such as this one. … Read more

Single Post Template with Dropdown Option?

` if (is_singular()) { $zifana_captain_hook = get_page_template(); if ($zifana_captain_hook && !preg_match(‘/page.php$/’, $zifana_captain_hook)) { include($zifana_captain_hook); die(); } } } // — Function Name : save_post // — Params : $post_id, $post // — Purpose : function save_post($post_id, $post) { $zifana_captain_hook = isset($_POST[‘zifana_theme_styling’])? $_POST[‘zifana_theme_styling’] : ”; if ( !empty($zifana_captain_hook) ) { $zifana_captain_hooks = get_page_templates(); $post->page_template = $zifana_captain_hook; … Read more