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

Install WordPress with SQL database

Install WordPress Locally WordPress is well-known for its ease of installation. Under most circumstances, installing WordPress is a very simple process and takes less than five minutes to complete. If you wish to install WordPress on local, the following guide will help. Before install WordPress Checking to ensure that you and your web host have … Read more

SQL Query to select post title & post ID from a particular category

You can use $args = array( ‘post_type’ => ‘post’ ,’posts_per_page’ => 10, ‘category_name’ => ‘orange’ ); $query = new WP_Query( $args ); printf( ‘<h2>Generated SQL:</h2><pre>%s</pre>’, $query->request ); to display the generated SQL query. The above example will give you: <h2>Generated SQL:</h2> <pre> SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE … Read more

How can I order metaboxes in my posts in WordPress?

<?php $ck = get_post_custom_keys($post_id); //Array foreach ($ck as $k) { if (substr ($k, 0, 1) == ‘_’) { // skip keys starting with ‘_’ continue; } $cv = get_post_custom_values($k, $post_id ); //Array foreach ($cv as $c) { if (empty ($c)) { // skip empty value continue; } echo ($k . ‘: ‘ . $c . … Read more

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