Support » Fixing WordPress » Getting the master parent page from the current page

  • Say I have these pages:

    Fruit (Parent)
    — Apple
    —- GrannySmith
    —- Fuji
    — Orange
    — Grape

    Vegetable
    — Carrot
    — Lettuce
    —- Iceburg
    —- Romaine

    Given a page, I would like to know what the master parent is. Any code out there that can do something like this?

    I imagine the function can take one argument (the current page) and spit out the master parent like:

    get_master(Fuji) -> Fruit
    get_master(Grape) -> Fruit
    get_master(Fruit) -> Fruit
    get_master(Lettuce) -> Vegetable

    This will be useful because I’ll be using this in header.php to customize the header image via different id’s.

    Thanks for any help.

Viewing 1 replies (of 1 total)
  • Couldn’t you just create new page templates?

    Assign fruit.php to be the page template for all sub-pages of Fruit, and there just use the fruit header image; then a vegetable.php to be the vegetable page template.

Viewing 1 replies (of 1 total)
  • The topic ‘Getting the master parent page from the current page’ is closed to new replies.