• So, I am sure this is another simple thing that millions have figured out. But looking through the forums I cant find a perfect fit for what I would like to do.

    I want to generate a list of ancestor pages and their links, but the catch is, I only want the ancestors of the page ID that I am on. I dont want allllll of the ancestors of alllll of the pages.

    If I only have one sidebar then I cant just enter the ID number as ’35’ or ’22’ I need to say get all the ancestors of post->ID

    I know this is so simple its on the tip of my tongue. Any helpers?

Viewing 1 replies (of 1 total)
  • eddowding

    (@eddowding)

    $ancestors = get_post_ancestors($post);

    if(in_array(17, $ancestors)) {
    // Code that will be parsed when this page has a ancestor with id 17
    }

Viewing 1 replies (of 1 total)
  • The topic ‘How to get ancestors with changing ID’ is closed to new replies.