[Support request] Custom message on search results page

Home Forums Support [Support request] Custom message on search results page

Home Forums Support Custom message on search results page

  • This topic has 5 replies, 3 voices, and was last updated 1 year ago by Leo.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1472851
    Grant

    Hello,

    I would like to add a custom message and embed a Google form to the search results page when the keyword returns no results. Here is an example:

    https://iafrika.org/search_gcse/?q=onetwothree

    So, if you search for “onetwothree” (or something else that isn’t in the content), it should not have the generic ‘no results’ response:

    “Sorry, but nothing matched your search terms. Please try again with some different keywords.”

    Rather, it should have a custom message and the Google Form into which uses can write what they were looking for (but did not find).

    What is the best way of doing this please?

    #1473405
    Leo
    Staff
    Customer Support

    Hi there,

    That’s not something the theme controls.

    I assume it’s using a plugin? If so you will need to check with the plugin support.

    #1474060
    Grant

    Hi Leo,

    Yes, it is using Relevanssi but that leverages off the standard WordPress search, which produces this message:

    Sorry, but nothing matched your search terms. Please try again with some different keywords.

    The plugin owner says:

    You need to modify the search results template from your theme, that’s where that message is coming from. There are few different variations on how themes do this, but the most common way is the search.php file – look for that in your theme.

    So, please could you tell me how to do this with GeneratePress and to add in the Google Form? Perhaps with a code snippet? I have the Code Snippets plugin installed.

    #1474114
    David
    Staff
    Customer Support

    Hi there,

    you would need to make a duplicate of the no-results.php in your child theme and make your changes there. I have highlighted the part that needs changing:

    https://github.com/tomusborne/generatepress/blob/35fe967ca7351a0517d258ab5c73150aa40d1f9a/no-results.php#L55-L60

    #1474824
    Grant

    Hi David,

    Thanks, I have edited the standard no-results.php and it works. I understand that a child theme is a better option for this as this file will be replaced next time the software is updated. But is it the only solution as I am running a multisite installation and will have to create a new child for each sub-domain? Is there no option to do this with code snippets or something else?

    Thanks,

    Grant

    #1474890
    Leo
    Staff
    Customer Support

    Unfortunately there is no filter for that so a child theme is required.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.