简体   繁体   中英

How to exclude certain classes from wordpress search?

On a WP-site I am using some div's with the class .exclude_from_search Therefore I would like these div's not to show up in the list of search-results. Is there any way to achieve this goal?

I found articles about excluding pages, categories, tags... But nothing about how to exclude classes.

The problem is basically that these div's contain always the same information. Something like "responsible: some name" If anybody searches for the word responsible, he will see all pages in the list of results. That is not helpfull.

I would suggest you to use a better search for that purpose. It is not possible to exclude an html element from wp search functionality per se.

The search looks for strings in your WP database. If a match is found, you see the result in your search results.

To get better control over your search results, and to implement a list of stop words and exclusions, you might want to try out the Relevanssi plugin. It comes with an explanatory GUI and should provide you with needed functionalities.

https://wordpress.org/plugins/relevanssi/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM