To display only assigned category you need to change hide_empty to true.
Please see the modified code:
$args = array(
'hierarchical' => 1,
'show_option_none' => '',
'hide_empty' => true,
'parent' => 134,
'taxonomy' => 'product_cat'
);
$subcats = get_categories($args);
echo '<ul class="wooc_sclist">';
foreach ($subcats as $sc) {
$link = get_term_link( $sc->slug, $sc->taxonomy );
echo '<li><a href="'. $link .'">'.$sc->name.'</a></li>';
}
echo '</ul>';
Please see the updated code:
$cats_list = get_the_terms ( get_the_ID() , 'product_cat' );
echo '<ul class="wooc_sclist">';
foreach ($cats_list as $cats) {
$link = get_term_link( $cats->slug, $cats->taxonomy );
echo '<li><a href="'. $link .'">'.$cats->name.'</a></li>';
}
echo '</ul>';
Related Posts:
- WordPress Ajax always returns a 404 error
- Calling a method from functions.php on a click of a button
- Nice scroll to wordpress
- Javascript code inside “” in core WordPress files .php
- Minify HTML, CSS, JS with PHPWee?
- Add HTML Attributes To Anchor Tags In `wp_list_categories()` Function
- Slide in Panel WordPress Post
- Show post in slider
- Populate dropdown with Child Pages based on Parent Page chosen
- search and replace preword from author
- WP grandchild categories in nested ul li
- How to change redirection route to a php page for making it only accessible by logged-in members?
- selected option if current category is the value
- parts of url disappear when using # inside href=”” [closed]
- Different post styles depending on category
- Noscript not working as it should in wordpress site
- get taxonomy thumbnail and use it as a variable in code
- Add Codepen animation as Preloader to WordPress
- HTML escaping data with ajax requests
- Override user-edit.php to design own profile page
- How to change logo by category
- Calling PHP Titles inside Javascript Markup
- Link to page with posts of specific type
- Replacing WordPress Icons (menu,icons32, etc)?
- go to home page when i select default in select-box
- Is it possible to isolate and use WordPress functions outside of wordpress
- Time Delay a URL Redirect for Specific Page
- Cascading dropdown select search based on Parent Page & Child Page
- WordPress cascading dropdown selection search based on Parent Page & Child Page
- Display WordPress search results based on the selected Sub-Category
- html form: redirect page after form completes submit function and posts data
- WordPress User Meta value variable into Google Gauge Chart
- List sub categories and corresponding posts of a parent category
- Search bar for wp menu
- Adding HTML Code to Replace Text in PHP
- Executing php on button press
- Add other class content with reference class value
- Using Google Analytics in an enqueued JS file
- separate list of programs in html/javascript coming from php
- How to enable HTML tags in category description without breaking the category page
- How to use wp_ajax_set_post_thumbnail?
- Passing a value from an input field to a php function in WordPress?
- How do I disable cache for a certain page?
- WordPress Slider is not working
- How can i show specific Category List?
- sessionStorage saves input value in browser but it is not loaded in the form field
- Collapsible menu on post sidebar only expands and does not collapse
- Target a specific container to style on WordPress storefront theme
- scroll scrpit to particular button position to next id when click button
- Bootstrap Carousel Indicators Won’t Cycle On Custom WordPress Theme
- Code works on page-example.php by not category-example.php
- Where to find the html for WordPress site? [closed]
- I need help implement a Javascript code into the PHP file
- Trying to customize wordpress drop down categories
- Is there a better way to output HTML as a shortcode?
- Load wp_editor on button click
- Slick slider not working on wordpress
- How do I refresh a DIV content?
- Local wordpress install only shows home page, all other pages Not Found
- Display current category title on category page
- How do I make an HTML table from a database table?
- How to get the custom header image’s alt text?
- Modify previous and next text from pagination links
- Inject post (from specific category) between posts in Loop
- Add a class to links in the visual editor (how to get old dialog back)
- Gutenberg Blocks doesn’t render correctly when using do_blocks
- Get post meta in enqueued js file
- How to use WordPress (PHP) functions in AngularJS partials files?
- How to create a custom config file and get data using inline JS in a wordpress page
- List all categories but exclude current post category on single post page
- Two posts in same div – WP loop
- Edit category output
- Archive dropdown styling not applied
- using woocommerce_template_single_add_to_cart in shop-loop – javascript issues [closed]
- Use WordPress’s Media Uploader/ Manager in non WordPress php application
- Get/Set wp.customize.previewer.previewUrl
- To echo or not to echo?
- Different background-image by category
- How to make custom total price reactive in navigation
- Adding tawk.to code just before body tag on functions.php file
- Correct syntax to html php conversion
- How can I output a php value into a JS file within WordPress?
- How to test nonce with AJAX – Plugin development
- Slider loading issue
- Getting a specific post values to another div or modal
- Creating a Multi-Level Associative Object Using AJAX
- remove wp floating submenu in wp dashboard
- How to complete two other input fields, completed the first
- how do I get a specific post from a post with a subcategory in WP
- Need Help Fixing My Iframes [closed]
- Get page that displays all children of taxonomy parent
- Passing UTM Parameters To Modify Page In WordPress
- Open post-content in archive page in a Modal box with bootstrap
- Creating own shortcode – echoeing php variable based on JS variable
- How to add a do_action on refreshing of WP customizer?
- Settings API callback function inserts html quotes from nowhere
- WordPress Multiple Navigation bars
- PhantomJS with wordpress
- Add / Update Custom Fields After Select Pictures in Media Window
- Login to wordpress by clicking a link and specifying usernaname and password in url