With the below, you are grabbing terms from the event_category taxonomy
Note that you are always grabbing the same terms though.
$terms = get_terms(
'event_category',
array(
'orderby' => 'count',
'hide_empty' => true
)
);
If you want to grab only from the current pages children, then you should grab the current term and set your term list to only grab children of the current term:
$current_term = $wp_query->queried_object;
$terms = get_terms(
'event_category',
array(
'orderby' => 'count',
'hide_empty' => true,
'parent' => $current_term->parent
)
);
Here you are cycling through them…
foreach( $terms as $term ) {
// Check and see if the term is a top-level parent. If so, don't display it.
$parent = $term->parent;
if ( $parent!='0' ) {
// Define the query
What are you trying to do with this query?
You are creating it, but then doing nothing with it.
$args = array(
'post_type' => 'events',
'event_category' => $term->slug
);
$query = new WP_Query( $args );
This just writes out a link:
echo'<a href="'.home_url().'/big-events/'.$term->slug.'"><span class="cat-name">' . $term->name . '</a>';
It might be better to do something like:
echo '<a href="' . get_permalink($term) . '"><span class="cat-name">' . $term->name . '</span></a>';
}
}
?>
rewritten a bit:
<?php
$current_term = $wp_query->queried_object;
$children = get_terms(
'event_category',
array(
'orderby' => 'count',
'hide_empty' => true,
'parent' => $current_term->parent
)
);
if ( !is_wp_error( $children ) && is_array( $children ) && 0 < count( $children ) ) {
foreach ( $children as $child_term ) {
$child_link = get_permalink( $child_term );
echo <<<HTML
<a href="https://wordpress.stackexchange.com/questions/176032/{$child_link}"><span class="cat-name">{$child_term->name}</span></a>
HTML;
}
} else {
# No child terms were found
}
?>