WordPress.org

Ready to get started?Download WordPress

Forums

Tabs - to identify topmost page parent (2 posts)

  1. Just Thomas Misund
    Member
    Posted 7 years ago #

    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.

  2. moshu
    Member
    Posted 7 years ago #

    The only way I could do something similar was this plugin:
    http://www.webspaceworks.com/resources/cat/wp-plugins/30/
    (actually, I am not using its fold feature - just the highlighting: parent page in top menu > subpages in the sidebar, and the top parent still highlighted when browsing the subpages)

Topic Closed

This topic has been closed to new replies.

About this Topic