search results filter (6 posts)

  1. xmatter
    Posted 5 years ago #

    Is there a way to filter search results if I have more then 1 of the exact same page? Meaning... 3 identical pages, do a search, the results display all 3. Can a script be written to only display 1 result for that page?

  2. xdesi
    Posted 5 years ago #

    Probably yes but what do you mean you have 3 identical pages? Can you give us an example, is there anything that connects the identical pages?

  3. xmatter
    Posted 5 years ago #

    Nothing connects them.

    Let's say the site's main menu is based on counties and there is a pizza shop the serves 4 counties, so I would place the same page (4 copies, 1 copy in each county they serve). That would give me 4 identical pages each with a different parent page (county).

  4. xdesi
    Posted 5 years ago #

    Which one of the 4 would you like to display, just anyone of them? I guess they all have the same page title?

    If so you could possibly store the title in an array and check if it's already been displayed and if so don't repeat it for example:

    //then page title hasn't been displayed yet
    //add it to array
    $titles[] = wp_title('',0);
    //display post stuff here

    That might work seeing as the title might be the only thing that connects them as a similarity to easily compare them by?

  5. xmatter
    Posted 5 years ago #

    that might work! you are correct that the Page Title is the only thing that would connect all of them together, being each will get it's own page_id. if this does work, i am wondering how i could bypass typing in each title if i happen to have thousands of pages. This is for a company intranet and i would use posts, but pages are the better option. Only the search is screwing this up.

  6. xdesi
    Posted 5 years ago #

    How do you mean typing in each title? The function wouldn't require this as it should automatically add every title displayed into the array and then if a repeat title comes along then it should do nothing and move onto the next post.

    I haven't tested this by the way but it should work assuming two pages have exactly the same title.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.