Support » Fixing WordPress » How to recover the top-level page ancestor slug or ID to use in HTML?

  • I’m working on a theme where I need to change some header text and an image depending on which part of the hierarchy of static pages the user is on.

    The text needs to be easily editable by the user, so I want to put it in a widget, while the image will be called by HTML rather than as a background image by CSS.

    In both cases I could accomplish this if I could recover some detail of the top level page ancestor, such as its ID or slug, and use it either with .jpg on the end to call an image or in the code used to call a widget.

    But my skills lie towards CSS and design, not PHP – can anyone advise how to do this? I have found the functions.php addition that adds the top level ancestor ID to the body classes, but don’t have the knowledge to make it work in the page itself.

    Thanks in advance,
    Andy

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to recover the top-level page ancestor slug or ID to use in HTML?’ is closed to new replies.