Order by rating not works in wp_query
You should use ‘orderby’ => ‘meta_value_num’ and ‘meta_key’ => ‘rating’ as specified by the WordPress Codec. Using meta_value_num with the assumption your ratings are numeric values Reference: Orderby Parameters
You should use ‘orderby’ => ‘meta_value_num’ and ‘meta_key’ => ‘rating’ as specified by the WordPress Codec. Using meta_value_num with the assumption your ratings are numeric values Reference: Orderby Parameters
All the data like different prices of a product custom post type are store (for each product) in postmeta table. To find the post id of all products you have to use this query on posts table: SELECT * FROM ‘posts’ WHERE ‘post_type’ = ‘product’ For each product id (post_id), you can retrieve all related … Read more
Firstly, the GUID is not the URL. It is a “globally unique identifier”. WordPress uses the URL for this purpose, but accessing it is not a reliable way to get the URL for anything (this was a bad idea, but is kept this way for backwards compatibility). It’s not possible to query the image URL … Read more
I solve This To get the current category ID. $cate = get_queried_object(); $cateID = $cate->term_id; echo $cateID; and it works like a charm.
<?php $product_id = ’14’; $product = new WC_product($product_id); $attachment_ids = $product->get_gallery_image_ids(); foreach( $attachment_ids as $attachment_id ) { // Display the image URL echo $Original_image_url = wp_get_attachment_url( $attachment_id ); // Display Image instead of URL echo wp_get_attachment_image($attachment_id, ‘full’); }?>
For serious reference, see how WC itself adds the textarea variable_description to the variations here. We notice multiple (potential) problems in your text field implementation. The missing name… The id string does not have a correct structure, it has the name structure instead… The id or name are not same than in your template… So … Read more
The WooCommerce template files are different from the WordPress Template files look at this to see how it works and the template file for shop pages is archive-product.php Usually, all themes provide a separate sidebar area for the shop page, did you check if your theme is compatible with WooCommerce? If yes then you should … Read more
It’s seems you have all variations same price. That’s why it’s not showing, it’s a WooCommerce default behavior. You can change this WooCommerce default variable price filter with this hook. add_filter(‘woocommerce_show_variation_price’, function() { return TRUE;});
On the Menus page, click the Screen Options tab at top right. Then tick the boxes for products and product categories. That will make them available to be added to your menus.
You can create a product object using the following function: $product = wc_get_product( $post_id ); And after that you will be able to access to all product’s data. All available methods can be found here, but the ones you need are: $product->get_regular_price(); $product->get_sale_price(); $product->get_price();