Filtering The Wordpress Search - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Thursday, July 20, 2023

Filtering The Wordpress Search

I need help with search.php on a theme i'm developing. Search Results are picking up url's from anchor tags in the_content();

I see many tutorials / code examples on how to exclude certain pages or posts from search results, but no way to be more specific about what i'm filtering within the content area.

For example lets call this site;

bestcars.com

When I search for cars, as expected my Custom Post Types's to do with CARS are showing, but also I'm seeing the CONTACT US page show up and the HOMEPAGE too.

Thats because within the CONTACT US page there is a button going to FIND US and because the url contains the word;

bestcars.com/find-us/

This is showing in the CARS results.

Ideally I want to filter;

  • the words within the base url only (if thats the only place they appear),
  • any meta data from images and alt text,
  • any urls or titles within anchor tags.

Can anybody help please?



source https://stackoverflow.com/questions/76723847/filtering-the-wordpress-search

No comments:

Post a Comment