Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Check parent category, check if parent category has sub categories, display sub categories of parent that have posts associated.
- $term = get_field('parent_category');
- if ($term) {
- $args = ['parent' => $term];
- $categories = get_categories($args);
- if (!empty($categories)) {
- echo '<div class="child-categories widget widget_categories">';
- echo '<h4>Categories</h4>';
- echo '<ul>';
- foreach ($categories as $category) {
- echo '<li><a href="' . get_category_link($category->term_id) . '" title="' . sprintf(__("View all posts in %s"), $category->name) . '" ' . '>' . $category->name . '</a></li>';
- }
- echo '</ul>';
- echo '</div>';
- }
- else {
- dynamic_sidebar('sidebar1');
- }
- }
- ?>
Add Comment
Please, Sign In to add comment