WP_Query for products always returns empty

Your arguments should look like this : $args = array( ‘post_type’ => ‘product’, // No need for an array since you only query one post type ‘posts_per_page’ => 3, ‘tax_query’=>array( // The taxonomy query array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘term_id’, // Can be omitted, default parameter, can also be ‘slug’ or ‘name’ (name should … Read more

How to change layout of shop page in wordpress? [closed]

Don’t use jQuery to place a image into your shop page (since there is proper way to do this). Instead read the template override methods in Woocommerce: https://docs.woothemes.com/document/template-structure/ Copy woocommerce folder into your theme (if you don’t have the folder inside main theme/child theme). Navigate to your_theme/woocommerce/templates/archive-product.php (this is just an example on how to … Read more

Show different menu on each woocommerce category page

This is the solution I found that works: As usual in these cases, override the archive product template from your woocommerce plugin folder by copying archive-product.php to yourtheme/woocommerce/archive-product.php. Edit the file, and add this code at the beginning (or wherever the menu needs to show up): <?php if ( is_tax( ‘product_cat’, ‘cat1’ )) { wp_nav_menu( … Read more

Woocommerce frontend edit custom fields

you don’t have to edit the order-details.php page the woocommerce_order_details_after_order_table action will achieve the same results. add_action( ‘woocommerce_order_details_after_order_table’, ‘namespace\custom_field_display_cust_order_meta’, 10, 1 ); function custom_field_display_cust_order_meta( $order ) { echo ‘<form [whatever]>’; /* translators: whatever */ echo ‘<p>’ . sprintf( __( ‘<strong>Property 1:</strong> %1$s (%2$s)’ ), ‘<input [whatever]>’ . get_post_meta( $order->get_order_number(), ‘property 1.1’, true ) . ‘</input>’, … Read more

Woocommerce Register Error

First you need to add a hidden field to registration form which can hold the URL where you want to redirect the user post registration. Below code will help you for that: <?php add_action( ‘register_form’, ‘hiddern_redirect_url’ ); function hiddern_redirect_url() { ?> <input type=”hidden” name=”redir_post_register” value=”<?php echo get_site_url(); ?>” /> <?php } ?> Then, using woocommerce_registration_redirect … Read more