0

We've a courses website where we want to filter posts/courses by the keywords present in the category and/or title. Currently when filtering, the keyword is also being searched in the post content which is what we want to exclude. Is there a way to exclude searching in the post content via a hook or filter in wordpress ?

Attached is the image of the search results where the first search result doesn't contain a computer word either in the title or the category but still it shows in the results.

Update Forgot to mention that it's a custom post type job_listing.

enter image description here

2
  • There is a posts_search hook you can use. Here's an example that searches only post titles: wordpress.stackexchange.com/questions/11822/… - you would basically copy most of the WP_Query class and remove the post_content LIKE part.
    – WebElaine
    Commented Dec 6, 2021 at 14:38
  • How would this work for both the post title & category ?@WebElaine
    – DavidG
    Commented Dec 6, 2021 at 14:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.