Here is a screen of settings:
The query loop displays both the parent and children above the title. How can I display only the parent?
Here is a screen of settings:
I’m afraid you wont’t be able to do that within your query-loop.
Maybe you could wrap that term-element (probably basic-text) inside a Div/Block-Element and query for your term with that Div/Block-element.
Or you use a code Element and try something like this (this is some ChatGPT created code):
<?php
// Define the taxonomy you want to query (e.g., 'category', 'custom_taxonomy').
$taxonomy = 'category'; // Replace with your desired taxonomy.
// Get the terms associated with the current post.
$current_post_id = get_the_ID();
$terms = wp_get_post_terms($current_post_id, $taxonomy, array(
'orderby' => 'name',
'order' => 'ASC',
));
// Filter to only include parent-level terms.
$parent_terms = array_filter($terms, function($term) {
return $term->parent === 0; // Only include terms with no parent.
});
// Display the parent-level terms.
if (!empty($parent_terms)) {
echo '<ul>';
foreach ($parent_terms as $term) {
echo '<li>' . esc_html($term->name) . '</li>';
}
echo '</ul>';
}
?>