WooCommerce: Display product categories to make IF statement

Try This Code <?php global $post; $terms = get_the_terms( $post->ID, ‘product_cat’ ); foreach ($terms as $term) { $product_cat_id = $term->term_id; break; } if ($product_cat_id == “6” && $product_cat_id == “7” ) { echo “aaabbb”; } else if ($product_cat_id == “6” ) { echo “aaa”; } else if ($product_cat_id == “7”) { echo “bbb”; } ?>

var_dump of WP_Query object is not empty, while .have_posts() return false

The WP_Query::have_posts takes into consideration just the current_post and post_count properties of the object ( see the Code Reference for more details ). And those are, in deed, empty in your var_dump: [“posts”]=> array(0) { } [“post_count”]=> int(0) [“current_post”]=> int(-1) So perhaps the query args are not correct and you are attempting to query something … Read more

Menu not adding the right items

You’ve defined your menu location as header_navigation. Use the menu location slug header_navigation in your call to wp_nav_menu(), not the description (nav): wp_nav_menu(array( ‘theme_location’ => ‘header_navigation’, ‘container’ => false, ‘menu_class’ => ‘nav’, ));

How To Customize The Product Page Template for a WooCommerce Custom Product Type Plugin [closed]

The cruxof my issues were a mis-matching class name/product type. I was calling the class WC_Product_Family but using a product type of “wcfp_family_product”. I refactored the code, adding in the hook for the add_to_cart and was able to get a crude working example: <?php /* https://wisdmlabs.com/blog/create-product-type-custom-settings-woocommerce/ Adding a custom WooCommerce product type // Example showing … Read more

Two Sections on Woocommerce Catergory Page [closed]

You have copy the archive-product.php in your template folder in the woocomerce folder. Then you edit the file and basically run a loop trough the catgeories you want (for example you category id’s are 12 and 24); $product_categories = array(12,24); foreach($product_categories as $category){ $product_options = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘product’, ‘orderby’ => ‘menu_order’, … Read more

Remove any product that is featured from regular display loop [WooCommerce]

Use the pre_get_posts filter to remove your sticked product from the product loop. add_action( ‘pre_get_posts’, ‘exclude_stycky_product’ ); function exclude_sticky_product(){ // target only the main query if ( ! is_admin() && $query->is_main_query() ) { $query->set(‘ignore_sticky_posts’); $query->set(‘meta_value’, ‘1’); } } Hope it helps you !