You can do it this way:
1 – get all child terms which belongs the term you want
$args = array(
'taxonomy' => 'product_cat',
'child_of' => 7, put here the id of parent term, which chldren you want to get
'hide_empty' => false,
);
$child_terms = get_terms( $args );
2 – loop through these terms and print there names and posts
if(!empty($child_terms)){
foreach($child_terms as $term){
$args = array(
'posts_per_page' => -1,
'post_type' => 'product',
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'term_id',
'terms' => $term->term_id,
)
),
'post_status' => 'publish',
);
$posts_array = get_posts( $args );
echo $term->name; // subterm name
foreach ($posts_array as $post) {
setup_postdata( $post );
the_title(); //subterm post
}
}
}
Related Posts:
- WooCommerce: How to edit the get_price_html
- Get woocommerce product price by id [closed]
- Woocommerce: How to remove page-title at the home/shop page but not category pages
- Hidden woocommerce products still showing up in search results [closed]
- Preventing WooCommerce email sending only on particular conditions
- Woocommerce view order link in customer emails
- Filter on a custom product attribute in WooCommerce using meta_query or tax_query [closed]
- Woocommerce : How to attach an custom attachment with customer-processing-order.php email template [closed]
- Is is safe to edit language files from wp-content/languages/plugins/woocommerce-ro_RO?
- Does the woocommerce_order_status_changed hook fire when WooCommerce updates an order status automatically? [closed]
- Display WooCommerce only in stock sizes product attribute on shop page
- Remove “Choose An Option” on Product Variation & Auto Select Instead
- check if current url/page equals checkout page [closed]
- Mini cart in header using divi is not getting updated on changing the cart items count:
- Woocommerce Product Price Inserted programmatically doesn’t get displayed In Single Product Page
- How to Order by random on a SQL query
- Move add to cart in Woocommerce
- Separate Categories from WC Product loop when display type is set to both on the category
- Remove Order List Row Link in WooCommerce Admin?
- How do I hide out of stock products from homepage but not from catalog?
- Woocommerce order processing email subject not changing
- Different translations for the same plugin inside a multisite
- Woocommerce multiple taxes with same rates adds as different values.
- function to add note on single Woo Commerce product page for downloadable variations
- Apply Additional Discount after coupon
- Woocommerce Porto Theme Hide Selected Categroy for Breadcrumbs
- Set specific number of columns for top level term on product category archives
- invalid menu item when upgrading to WordPress 5.5
- Register a new user on wooCommerce using Rest API
- Showing the WordPress standard text area on a Woocommerce Single Product Page?
- Woocommerce custom search
- How to be able to edit custom address fields in WooCommerce admin?
- WooCommerce orderby template disappears and not longer works on search page
- Woocommerce variations as a list [closed]
- Sort & Display WooCommerce Product Attributes by Order
- Adding product info for printing to custom Woocommerce Product Display tab [closed]
- wp_set_object_terms being undone
- How to search variable product by its variation id in woocommerce admin product search box?
- Add shipping address to Woocommerce order emails [closed]
- A function to add arguments to a taxonomy
- Hide inventory message on product page based on available stock quantity
- Different Templates for Woocommerce Parent and Child Sub Categories
- add sub subpage endpoint to woocommerce plugin my-account section
- Clients with empty username are not receiving request new password email
- how can i add an additional action into woocommerce admin order page through my plugin?
- Woocommerce changing add to cart button text as icon [closed]
- how to change the “return to shop” button text? [closed]
- Display data when category is empty
- Disable woocommerce PLACE ORDER button if user selected products that are not available for international delivery
- Remove sale signs from site in branded? [closed]
- Create a regular post for every WooCommerce order
- How do I create a filter to hide the One Click Accessibility plugin button in WordPress?
- customers are not showing up in woocommerce
- Hooks For Design variation in woo commerce single product page
- Dokan stock management
- Access custom meta_data in processing order email
- Woocommerce : How to automatically input the same email for every order?
- Woocommerce – Change order of products in Confirmed Order
- echo product parent category
- How to edit wc_get_template_part for archive products
- Switch to user link shortcode
- Woocommerce – how to round up all prices to end in .99
- Display WooCommerce product attribute on shop page
- How to get product category ID based on post?
- Jump to Footer On Scroll – Woocommerce Pages Phones Only
- WordPress Development Workflow
- How do I disable “Flat Rate” radio button and remain with other shipping method in woocommerce
- How to add woocommerce product price filter widget to other page
- Remove Stripe Woocommerce Credit Card Icons (and replace with image)
- How to add external product url to woocommerce from a metadata by function.php
- Unable to call woocommerce hook in my custom php file
- Custom account page that accepts a query parameter
- Custom WooCommerce template for product
- Checkout fr Woocommerce – load default WooCommerce checkout template on the fly
- Loop Through Current Woocommerce Product Categories Sub Categories
- Two types of product categories on shop page
- Remove username and account password field from checkout page
- How to send an automatic email to a custom field in Woocommerce order meta 2 weeks after a product is bought
- Woocommerce cart table too wide [closed]
- HTTP Error when uploading pictures and problem with the size of images
- add_rewrite_rule() returns 404 page
- WooCommerce CSV Image URL Creates Additional Images in Media Folder
- Custom changes performed on WP + WooCom site on maintenance subdomain. How to perform a migration to a main domain?
- Woocommerce Setup not completing
- How to restrict type/size of file uploads in any plugin?
- In woocommerce some products have empty options, but how to check this
- WooCommerce – Adding Product Attributes to CSV Export
- Unable to enocde the result of wc_get_products
- Woocommerce Add to Cart function
- WooCommerce – doesn’t show product when using woocommerce.php [closed]
- Remove Span Class From Woocommerce Price
- How to show woocommerce login / registration form in modal
- Notice: Trying to get property of non-object in bodycenter [closed]
- WooCommerce remove billing detail completly
- unable to get product by category only getting product added lastly
- error 500 in Back Office when using a woocommerce function in functions.php
- How to update all products with same SKU prefixes when updating stock with CSV?
- What is the best and cheapest way to generate dashboards about conversions data and store users? [closed]
- Sort by price when price is set in multiple keys
- Add a custom code with custom link after add to cart for every product