• Skip to content
  • Skip to primary sidebar

Hire Jordan Smith

  • About
  • Portfolio
    ▼
    • Web Design
    • Logo Design
  • Services
    ▼
    • All Services
    • Web Design
    • Logo Design
    • SEO Services
    • Web Hosting
  • Reviews
  • FAQ
  • Blog
  • Hire Me
  • About
  • Portfolio
    • Web Design
    • Logo Design
  • Services
    • All Services
    • Web Design
    • Logo Design
    • SEO Services
    • Web Hosting
  • Reviews
  • FAQ
  • Blog
  • Hire Me
HomeBlog Web DevelopmentHow to display only children of the current term

How to display only children of the current term

Share
Tweet
Share
+1
Pin
0 Shares
<?php
// How to only get children of the current term
?>
<div class="category-list">
<?php
$term_id = get_queried_object()->term_id;
$term = get_term($term_id, 'product_cat' );
$args = array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => false,
'child_of' => $term->term_id,
'parent' => $term->term_id
);
$sub_terms = get_terms( 'product_cat', $args);
//print_rr($subproducts);
foreach ($sub_terms as $term) { ?>
<li> <a href="<?php echo get_term_link( $term ); ?>"><?php echo $term->name; ?><?php /*echo "<span class='count'>" . $subproduct->count . "</span>"; */ ?></a></li>
<?php } ?>
</div>
view raw display-children-of-current-term.php hosted with ❤ by GitHub
Share
Tweet
Share
+1
Pin
0 Shares

Related Posts

  • How to Get the Current Page URL with PHP

    I worked on a project recently where I needed to get the url of the current page dynamically then add it to a body class. The first part of this…

  • Quick WP Query Call

    A simple WP Query Call, meant to be grab and go.

  • Useful WooCommerce Snippets

    This is a running list of snippets and plugins that I've found useful while developing in WooCommerce. If you are using the WC Brands extension, you will quicly realize that…

  • How to remove the WooCommerce results count

    Looking for a way to remove the WooCommerce results count? This is the result text that shows up on the WooCommerce product archive pages that displays the amount of products…

  • How to query for a single term in a custom post type

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Categories

  • SEO
  • Web Design
  • Web Development
    • ACF Development
    • BX Slider
    • Genesis Development
    • Gravity Forms Development
    • jQuery Development
    • Materialize Development
    • WooCommerce Development
    • WordPress Development

Quick Connect

Phone
912-656-6434

Email
jordan@hirejordansmith.com

Address
Hire Jordan Smith, LLC.
580 White Oak Lane
Richmond Hill, GA 31324

  • Facebook
  • Twitter
  • Linkedin
  • Google
  • About
  • Portfolio
  • Services
  • Savannah Website Design
  • Reviews
  • FAQ
  • Blog
  • Hire Me
  • Sitemap

© 2019 Hire Jordan Smith