What’s the code generating the menu?
Thread Starter
Anonymous User 13922460
(@anonymized-13922460)
Sadly, I am not sure. How can I find out? The menu is a category page.
I feel like I’m learning more and more about wordpress, and whenever I learn something new, there’s a dozen things I realize I don’t know. Thanks for helping me out 🙂
Thread Starter
Anonymous User 13922460
(@anonymized-13922460)
I suspect the theme only uses the general wordpress settings – yet I need to find a way to change those, without changing the core files.
Thread Starter
Anonymous User 13922460
(@anonymized-13922460)
Ok, I think I might have found the file (sub-terms.php).
The code for the whole file is the following:
<?php if ( is_taxonomy_hierarchical( get_queried_object()->taxonomy ) ) : // If the taxonomy is hierarchical. ?>
<?php $terms = wp_list_categories(
array(
'taxonomy' => get_queried_object()->taxonomy,
'child_of' => get_queried_object_id(),
'depth' => 1,
'title_li' => false,
'show_option_none' => false,
'echo' => false
)
); ?>
<?php if ( !empty( $terms ) ) : // If a list of child categories/terms was found. ?>
<nav <?php hybrid_attr( 'menu', 'sub-terms' ); ?>>
<ul id="menu-sub-terms-items" class="menu-items">
<?php echo $terms; ?>
</ul><!-- .sub-terms -->
</nav><!-- .menu -->
<?php endif; // End check for list. ?>
<?php endif; // End check for hierarchy. ?>
Really appreciate your help!
Add ‘hide_empty’ => 0 to that array?
Thread Starter
Anonymous User 13922460
(@anonymized-13922460)
Where would I add it?
Also, would it perhaps be possible to change the ” <?php if ( !empty( $terms ) ) : // If a list of child categories/terms was found. ?> “?
Anywhere in that array? So:
<?php $terms = wp_list_categories(
array(
'taxonomy' => get_queried_object()->taxonomy,
'child_of' => get_queried_object_id(),
'depth' => 1,
'hide_empty' => 0,
'title_li' => false,
'show_option_none' => false,
'echo' => false
)
); ?>
What’s the other thing you’re trying to change?
Thread Starter
Anonymous User 13922460
(@anonymized-13922460)
That didn’t solve it.
I am starting to think that the if function is what causes the problem. Right now it says if it’s not empty (!empty), show the menu (or?). How could I rewrite it so that the if function is removed completely? So that the function works whether it’s empty or not.
That’s not how the function is working. It’s saying “if there is any output, do the output,” not “If the category is not empty, show the category.”
So is your list not appearing AT ALL, or is it only showing populated terms?
Thread Starter
Anonymous User 13922460
(@anonymized-13922460)
It is only showing sub categories with posts.
It’s a sub-term menu on a category page with sub categories. If there are sub categories with posts, it will show those with posts. If there are both sub categories with posts and without, it will only show those with posts. If there are sub categories without posts, it won’t show at all.
Thread Starter
Anonymous User 13922460
(@anonymized-13922460)
Ah, I found it! Or, more like, you did.
You were right all along. The problem was that my child theme wouldn’t catch the php file. When I added 'hide_empty' => 0, in the main file, that solved everything.
Thank you so much for your help. Sorry about me blandering about and making mistakes. I’m still learning 🙂