Top-most Parent Category Name
-
I want to have a universal body tag that gets assigned a unique id based on the top-most parent category of the current view, whether it be single post, archive, category, whatever. I basically want to do dynamic highlighting on the nav but without all that php. It could be done easier in CSS if I could just get the parent category name on every page.
Is this possible in WP?
Example: I have a shared header file that gets called on every page view. Inside that header file is a body tag like so:
<body id="sect-<?php the_parent_category(); ?>">
I want something equivalent to
<?php the_parent_category(); ?>
.Then in my CSS I define the nav states depending on that id in the body. The site will only have 4 or 5 main nav points so the CSS could be very clean and would force the browser to render the nav state rather than pushing it onto the server like the PHP method.
Can anyone help me with this? Thank you.
- The topic ‘Top-most Parent Category Name’ is closed to new replies.