adam.codefor
Member
Posted 3 years ago #
I have a home page and a news page.
News page is my blog, when on the news page or homepage the relevent item in my navigation gets the class 'current_page_item' so I can highlight it in CSS - this works fine.
The problem is when I go to a post in the news page the news page item in my navigation is not getting passed 'current_page_item' or 'current_page_ancestor'?! I can see the lodgic in classes.php but it seems like it doesn't work correctly, any help?
This has got me stumped.
Thanks
adam.codefor
Member
Posted 3 years ago #
I just noticed if I echo out the parent of the page i am on like so:
<?php echo '<a href="'.get_permalink($post->post_parent).'">'.get_the_title($post->post_parent).'</a>'; ?>
each of the post page parents are echoing as themselves and not news? Its like they are not assosiated with the news page?
adam.codefor
Member
Posted 3 years ago #
Hmm I have still had no look with this, I would of thought its something that all wordpress blogs with a homepage would want?! It works fine for other pages that have parents just not the post<blog...
adam.codefor
Member
Posted 3 years ago #
Aries-Belgium
Member
Posted 3 years ago #
Hi adam.codefor,
I just had the same problem. For me it was a plugin that was causing problems. Luckily one of my own so I could resolve the issue. The problem is that the plugin calls the get_pages() function and that that array gets cached so the wp_list_pages() function will read that cache instead of fetching it out of the database. For some reason the current_page_ancestor class doesn't get set then.
The only thing I could do was flushing the cache (=wp_cache_flush()) to force WP to rebuild the cache and then it worked.