- This topic has 5 replies, 2 voices, and was last updated 1 year, 5 months ago by Ernest Marcinko.
-
AuthorPosts
-
April 3, 2023 at 12:49 pm #42085DOZ23Participant
The website contains almost 2400 pages. With the search box we want to search by place name. For example Amsterdam. Only posts with the words ‘City Game’ in the title should appear in the search results. The other posts do not need to be displayed.
How can you set a filter that only posts with the title ‘City Game’ are displayed?Thanks in advanced!
April 3, 2023 at 1:09 pm #42090Ernest MarcinkoKeymasterHi,
Thank you for all the details!
Are there many other pages you don’t want to show? If there are only a few, then maybe you could try to exclude them via these settings.
If there are too many to exclude one-by-one, then are the pages categorized in any way? Excluding or inlcuding by categories is the easiest way to restrict the results to specific taxonomy terms only.April 3, 2023 at 1:16 pm #42091DOZ23ParticipantHi Ernest,
There are many other pages that we dont want to show. The pages don’t have a category like the posts.
The easiest way would be to include only pages that contain the words City Game.
Best,
Ivo VisserApril 3, 2023 at 1:26 pm #42092Ernest MarcinkoKeymasterOkay. That is not going to be super easy, it will definitely require some custom coding to push an argument for the search phrase. Enforcing an restriction on the searched fields is generally not the best idea, but there is probably a way to do this.
Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.
add_filter( 'asp_search_phrase_before_cleaning', 'asp_search_phrase_before_cleaning_add', 10,3 ); function asp_search_phrase_before_cleaning_add($phrase) { return '"city game" ' . $phrase; }
April 3, 2023 at 1:32 pm #42093DOZ23ParticipantThank you very much Ernest. This feature does exactly what I want.
Best,
Ivo VisserApril 3, 2023 at 2:16 pm #42094Ernest MarcinkoKeymasterYou cannot access this content.
-
AuthorPosts
- You must be logged in to reply to this topic.