• 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?

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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?

    Thread Starter xmatter

    (@xmatter)

    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).

    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:

    if(!in_array(wp_title('',0),$titles){
    //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?

    Thread Starter xmatter

    (@xmatter)

    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.

    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘search results filter’ is closed to new replies.