Show only results based on a number of words in the title

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Show only results based on a number of words in the title

This topic contains 5 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 1 year, 5 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #42085
    DOZ23
    DOZ23
    Participant

    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!

    • This topic was modified 1 year, 5 months ago by DOZ23 .
    #42090
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #42091
    DOZ23
    DOZ23
    Participant

    Hi 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 Visser

    #42092
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Okay. 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;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #42093
    DOZ23
    DOZ23
    Participant

    Thank you very much Ernest. This feature does exactly what I want.

    Best,
    Ivo Visser

    #42094
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.