Created
June 20, 2019 11:02
-
-
Save rajucs/3f668ec03840f3ee10d4884eb83005ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $taxonomyName = "product_cat"; | |
| //This gets top layer terms only. This is done by setting parent to 0. | |
| $parent_terms = get_terms($taxonomyName, array('parent' => 0, 'orderby' => 'slug', 'hide_empty' => false)); | |
| echo '<ul>'; | |
| foreach ($parent_terms as $pterm) { | |
| //show parent categories | |
| echo '<li><a href="' . get_term_link($pterm->name, $taxonomyName) . '">' . $pterm->name . '</a></li>'; | |
| $thumbnail_id = get_woocommerce_term_meta($pterm->term_id, 'thumbnail_id', true); | |
| // get the image URL for parent category | |
| $image = wp_get_attachment_url($thumbnail_id); | |
| // print the IMG HTML for parent category | |
| echo "<img src='{$image}' alt='' width='400' height='400' />"; | |
| } | |
| echo '</ul>'; | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment