How to offer a link/button/contactform if "No results!"

Home Forums Product Support Forums Ajax Search Pro for WordPress Support How to offer a link/button/contactform if "No results!"

This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 6 years ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #8862
    Ramiro Ramirez
    Ramiro Ramirez
    Participant

    Hi there, great work!

    I have two quick questions:

    How can I offer a link or button or contact form when there are no results to display. So instead of showing the “No Results!” message the user can see a link to something else (probably a button to call a popup).
    I don’t mind tweaking the code a bit if is necessary.

    The other question: How can I set the results preferences so it shows a page rather than a category.

    In my case I have a category for a product (using WooCommerce), called “Something”. But when the user types “Something” I would like the results to display not that category but a Page called “Something” instead.

    Thanks for your time!
    R.

    #8877
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    Thanks for your kind words!

    I think you are looking for the results templating knowledge base article. There are basically template files for results, including the “No results” template. You are looking for the ajax-search-pro/includes/views/reuslts/no-results.php file. That file is parsed when there are no results at all. You can ad anything you want to that.

    If I understand correctly you want to display the page related to the term instead of the term. In that case use the Search in terms? option on the General Options -> Sources panel: https://i.imgur.com/TN37T5b.png

    Best,
    Ernest Marcinko

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


    #8915
    Ramiro Ramirez
    Ramiro Ramirez
    Participant

    Hi Ernest,

    Thanks for your help.

    Unfortunately I still can’t solve any of my previous questions.

    I’m using the Index Table feature, and I already had disabled the indexing of terms, categories, etc. But when I search for the Page Title I still get the Category instead.

    Regarding the no-results template. I’ve tried to override it through my theme, and is not working at all. I’m using a child theme, so I tried to create the asp folder in both the parent theme and the child theme. But still no change is been reflected on the results.

    #8920
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    Just to make sure, please check that the “product” post type is selected on the General Options -> Sources panel.

    Then please check the General Options -> Sources 2 panel on the search options, and make sure that no taxonomies are selected to be returned. (if you don’t want them to be returned of course, I believe you don’t)

    If you are using the index table, and want to return the page relevant to the term name (instead of the category), you need to enable indexing for that taxonomy term (category, product category or with a similar name I guess). That way if the category (term) is selected for that particular page, it ‘s title will be indexed alongside with that post.

    There is indeed a bug in that template file, I was able to re-create it on a fresh installation. I’ve made a tiny mistake in the code, whereas it checks for the “keyword-suggestions.php” file in the /asp/ directory, but includes the no-results.php correctly. Sorry about that.

    The resolution is to copy over the keyword-suggestions.php file as well from the ajax-search-pro/includes/views/results/ folder to the /asp/ subfolder in your parent theme directory.

    Note: The wordpress function reference tells me that the /asp/ folder needs to be in the parent theme directory, as the plugin is using the get_template_directory() call to get the theme directory – which turns out to always return the parent theme directory, no matter what.

    Best,
    Ernest Marcinko

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


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

You must be logged in to reply to this topic.