WordPress.org

Support

Support » How-To and Troubleshooting » Tabs – to identify topmost page parent

Tabs – to identify topmost page parent

  • I want to build a site with a whole lot of Pages (that is WordPress Pages), with the topmost parent Page serving as a category tab in my navigation menu.

    I’ve figured out how to apply custom CSS to a tab if the Page’s parent is the topmost parent, like this:

    <?php if (get_the_title($post->post_parent) == "TopmostPageName") {echo('id="chosen-tab" ');} ?>

    but is there any way to make this work in cases where the Page is the subpage of a subpage as well? Something like:

    if (get_the_title($post->post_topmost_parent) == "TopmostPageName")

    ?

    I can’t find any such template tag in the codex, so if it doesn’t work, could something like this be coded (but restrained to two subpage-levels) :

    if (get_the_title($post->post_parent) == "TopmostPageName" || get_the_title($post_parent->post_parent) == "TopmostPage Name")

    ?

    My PHP skills aren’t quite well, but I’m trying to hack WP the best I can. If someone could help I would be very grateful.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Tabs – to identify topmost page parent’ is closed to new replies.
Skip to toolbar