Support » Fixing WordPress » How to display a page ancestor on search result

  • Hi, guys,

    Here’s my problem:

    I need to customize a search results page like this: when the result is a page, I need to display the title and that page’s ancestors if there is any. Ex.:

    Page title
    page great-ancestor > page ancestor > page

    That’s because I have many pages with the same name inside different sections of the site and if I don’t display the page ancestor, the search results become useless, simply listing a series of pages with the same name.

    That would be like telling in which category a post was published. In my template, if the result is a post than it would display:

    Post title
    Published on: parent-category > category > post

    I think the answer must be something like the code mentioned here:

    But in that case, I know the page id and im my case I don’t.

    Could someone help me, please!

  • The topic ‘How to display a page ancestor on search result’ is closed to new replies.