WooCommerce – Multiple meta query not working

meta_query format and orderby format should be as follows: $args = array( ‘post_type’ => ‘product’, ‘post_status’ => ‘publish’, ‘posts_per_page’=> 10, ‘orderby’ => ‘total_sales’, ‘order’ => ‘DESC’, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘_featured’, ‘value’ => ‘yes’, ‘compare’ => ‘=’ ), array( ‘key’ => ‘total_sales’, ‘value’ => ’10’, ‘compare’ => ‘>=’ ) ) … Read more

Reduce Drop down Menu Width in WordPress

It’s a css issue. You need to edit two selectors. First is the menu width. It’s set to 100% which is why you’re seeing black space. Edit this class below.: .cap-primary-menu .menu > li.menu-full-width .cap-submenu-ddown { padding: 20px 25px 25px; width: 100%; // set this to auto or something smaller than 100% left: 0; border: … Read more

Get post from custom post type order by two taxonomies

You’re close, syntax is just slightly off. I can’t quite work out how/what terms you need to query for, but this should be the structure of your arguments: $query = new WP_Query( array( ‘post_type’ => ‘product’, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘term_id’, ‘terms’ => $ids_of_product_cat_terms, … Read more

Automatically add attributes to woocommerce product?

add_action( ‘save_post_product’, ‘create_product’, 10 ); function create_product( $post_id, $post) { // $post_id and $post are required if ( empty( $post_id ) || empty( $post ) ) { return; } // Dont’ save meta boxes for revisions or autosaves if ( defined( ‘DOING_AUTOSAVE’ ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) … Read more

Order Woocommerce Products by Latest Reviewed

WooCommerce includes several options in the core plugin for sorting your products on the Shop page. However, most people don’t realize that there’s actually an option for WooCommerce custom product sorting. By default, you’re given 6 options: Default Sorting (custom + name) Popularity (sales) Average rating Most recent Sort by price (ascending) Sort by price … Read more

WooCommerce Images are uploading to the server but not attaching

I think that you have made a mistake in the last line. array_push is not doing what you are trying to achieve (check the Manual) same as update_post_meta accepts different arguments. Besides that WooCommerce is storing galleries in simple comma separated list like 1,45,78,34 so you should change the last line update_post_meta($post_id, array_push($post_id, ‘_product_image_gallery’, $id)); … Read more