Jump to content
Sign in to follow this  
onokazugmailcom

[iBlogPro 4.2.4] Hide the title of grandchildnav widget if no children?

Recommended Posts

onokazugmailcom

The grandchildnav widget on the sidebar displays the h3 title even when there is no child pages to display. It would be nice to have an option to automatically/manually hide the widget if no content to display. iBlogPro 4.2.4

Share this post


Link to post
Share on other sites
Kate

Hi Onokazu - Do you have a link to your site? We may be able to come up with a solution in the meantime.

Share this post


Link to post
Share on other sites
onokazugmailcom

My site is on my local PC so I cannot show it to you right now. However, I managed to fix the problem by modifying library/_grandchildnav.php. Here is the content of modified and cleaned up version of the file: ` <?php if (!isset($post) || is_search()) return; if (property_exists($post, 'ancestors')) { $ancestors_array = $post->ancestors; } else { $ancestors_array = array(); } if (($post->post_parent && wp_list_pages("title_li=&child_of=".$post->ID."&echo=0")) || count($ancestors_array) >= 2 ) { if (count($ancestors_array)==1) { $subnavpost = get_post($post->ID); $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&sort_column=menu_order"); }else{ $reverse_ancestors = array_reverse($ancestors_array); $subnavpost = get_post($reverse_ancestors[1]); $children = wp_list_pages("title_li=&child_of=".$reverse_ancestors[1]."&echo=0&sort_column=menu_order"); } if ($children) { ?>

<?php echo $subnavpost->post_title;?>

  • <?php echo $children;?>
<?php } } `

Share this post


Link to post
Share on other sites
onokazugmailcom

I think I now know why I have this problem only on certain pages. It's because my custom plugin is excluding several leaf pages using the wp_list_pages_excludes WordPress filter. Those pages will not display but the original code of _grandchildnav.php thinks that those hidden pages exist in the list of pages fetched with the wp_list_pages function. I know not many plugins use the filter to exclude pages from being displayed, but it would be nice if the fix be included in the future versions of iBlogPro.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×