Use this
$product_terms = wp_get_object_terms( 17, 'product_cat', array( 'fields' => 'all' ) );
and then get the parent cat id and move all sub cat into an array.
Related Posts:
- Disable email notification after change of password
- Proper Way to Modify Plugin
- Get a list of all WordPress.org Plugins?
- Schedule WordPress Auto-Updates to only run during business hours
- Run WP-CLI using PHP
- How To Determine If A Filter Is Called In A Sidebar/Widget Context?
- Function to Set Product type in Woocommerce [closed]
- Filter Hook on plugin update
- Generic plugin (de)activation hook?
- Is the WordPress HTTPS Plugin Still Safe To Use? [closed]
- Calling function from within functions.php returns unwanted value
- How to prefix `attachment` permalinks with `attachment`?
- How do I register a stylesheet inside a WordPress widget?
- add function to saving change on Options Pages
- List users except current user using wp_dropdown_user? [closed]
- Opendir and WordPress Path
- Has anyone used require.js for handling plugin scripts?
- Edits to plugin not taking effect
- Multisite Backup Plugin [closed]
- Multiple files in a plugin
- WordPress plugin for affiliate referral system
- Make the checkbox meta field checked by default
- adding a new value to a serialized array in WP_option table
- WordPress 5 upgrade: until when is it safe to keep project running in 4.x?
- Write to / remove from default .htaccess file from plugin?
- How to Use Parameters with a Do_Action Function Within PHP Tags
- How do I pass a post ID to the page URL?
- Allow HTML in Excerpts in Elementor
- Need to change url paramenter of share product pintrest [closed]
- Calculate price and display on woocommerce product single page under price (simple price, variable price) [closed]
- Classified ad website : which solutions to use? [closed]
- wp_redirect() Error in Custom Plugin
- Bootstrap and Custom CSS in custom plugin are being overwritten by theme
- Loading a purchased jquery plugin in a wordpress theme
- Fullscreen Video/GIF Intro
- Multisite for Multisite?
- Basic function call on init failing
- Display a consistent Google Plus icon on ALL pages of my site
- breadcrumb need to show all pages and subpages
- Widget’s container?
- Is it possible not to load theme on a specific page in wordpress?
- How to change shortcode’s default theme?
- How to accept images at multiple sizes and aspect ratios and display as standardized image size / ratio?
- Mutliple users editing single document in wordspress
- Plugin: connect to external database without showing password
- wp_insert_post() inside save_post(): force WP to not update global post object?
- Woocommerce: Set thumbnail detail (clipping area)
- Filtered content appears in the excerpt
- My plugin does not install correctly if a previous version is still installed
- How to disable Wp-PageNavi at the top of the page
- Why aren’t my Follow Me links working?
- WordPress ping spam issue with Ping services?
- Hook from plugin doesn’t fire up from external PHP script
- Custom User Registration Form not showing
- Drag and drop widget always inserts image
- SMTP emails not picking up the correct From name and From email
- What database state changes happen after a post is manually “updated” with no changes?
- Display posts by alphabetical order
- wp_insert_post not inserting post from XML
- custom fields not displaying on wordpress site
- Overriding a function in a WordPress plugin
- after logout session not destroy from server/website side
- How To Toggle User_Meta in frontend in a form using PHP
- How to update a database entry with a wordpress plugin?
- Change Woo Custom Endpoint Titles from a Plugin
- Is there a way to display multiple authors on a post?
- custom sidebar plugin issue
- White blank screen while adding or editing pages in wordpress
- How can I store user preferences in WordPress and retreive them later?
- Plugin debugging with errors in activation routine
- one admin for 2 wordpress websites
- DB Sync Media Files extension [closed]
- Disqus comment system – change comments number before “load more” button
- Disable default posts (Posts,Pages,Comments and Media) in wp-admin
- How to get rid of error message of custom metabox in dashboard when moving out of edit page?
- W3 Total Cache Can’t Really Detect Things
- Is it right way to create shortcode?
- Storing values in Post Meta vs new tables
- Determine if get_the_image has image on Get the image Plugin
- Translate Woosidebars plugin strings
- How to add different CSS for galleries
- How do I add php to all links automatically?
- Why my site loads too Slow? [closed]
- Plugin Links to page not working
- Q&A lite plugin comments
- Integrating WordPress Content into a jQuery Slider
- Serious social interaction [closed]
- WordPress file manager plugin [closed]
- How to display multiple images in the before and after plugin?
- Redirecting to page on form submit – Revue plugin
- Create WordPress category dynamically
- Plugin Icon does not work correctly
- Redirect a specific User role not admins automatically to view the post that they just updated
- REST API – filters not working inside plugin class
- Advanced Custom Fields (ACF) and their Javascript API
- WordPress site server getting blocked due to resource abuse
- WORDPRESS ,Can’t load image of post when sharing post via facebook [closed]
- rest_cannot_update error
- How can I rename roles in a WordPress multisite installation?
- Load a custom post type template.html from a plugin