Change SearchAction Target Schema

#111273
  • Resolved Anirban Roy
    Rank Math free

    Hello!

    Currently, Rank Math generates this in the schema:

       "potentialAction": {
                    "@type": "SearchAction",
                    "target": "https://www.techrbun.com/?s={search_term_string}",
                    "query-input": "required name=search_term_string"
                }

    Although the target https://www.techrbun.com/?s={search_term_string} is correct as per WordPress native search, I am currently using Google’s Custom Search and for that, the target is https://www.techrbun.com/search/?q={search_term_string}

    Kindly let me know how to change that. Thank you!

Viewing 1 replies (of 1 total)
  • Hello,

    Sorry for the delay. We seem to have missed this ticket and the other one you replied on.

    You can definitely do that using this filter in your theme’s functions.php file:
    https://rankmath.com/kb/filters-hooks-api-developer/#sitelinks-searchbox

    /**
     * Allows filtering of the search URL.
     *
     * @param string $search_url The search URL for this site with a <code>{search_term_string}</code> variable.
     */
    add_filter( 'rank_math/json_ld/search_url',  function( $url ) {
        return $url;
    });

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘Change SearchAction Target Schema’ is closed to new replies.