Custom query parameter not defined in target URL

#314369
  • Resolved Dazze Studio
    Rank Math business

    Hey! Hope all is well.

    I received the below email from Google Search Console for another website we manage, we created a ticket previously about the same issue here #310207;

    =======

    Sitelinks searchbox issues detected on gentlewench.com

    To the owner of gentlewench.com:

    Search Console has identified that your site is affected by 1 Sitelinks searchbox issues:

    Top Errors

    Errors can prevent your page or feature from appearing in Search results. The following errors were found on your site:

    Custom query parameter not defined in target URL

    We recommend that you fix these issues when possible to enable the best experience and coverage in Google Search.

    =======

    I have uploaded the file rank-math.php to the Theme directory but the validation is still not fixing things. Please can you confirm the URL we have included is correct?

    The code is below.

    Thanks


    <?php
    // Rank Math - removing error in Google Console
    add_filter( 'rank_math/json_ld/search_url', function( $url ) {
    if ( 'en' === ICL_LANGUAGE_CODE ) {
    return 'https://www.gentlewench.com/?post_type=products&s={search_term_string}&lang=zh-hans';
    }
    return $url;
    } );

Viewing 5 replies - 1 through 5 (of 5 total)
  • Prabhat
    Rank Math agency

    Hello,

    Thank you for contacting us and we regret the inconvenience caused.

    As per your screenshot in the previous ticket, I tested this website with the language parameter but the Sitelink Searchbox schema is already validating properly.

    Could you confirm if the error for this website is also shown on the language parameter?

    Looking forward to hearing back from you.

    Thank you.

    Hi Prabhat, thank you the reply. This is in relation to the Chinese language we have here https://www.gentlewench.com/?lang=zh-hans and the Search link – you can see the reference to the language in the code I supplied.

    Please could you check again? https://search.google.com/test/rich-results/result?id=SL0-tc9griKjAntvDuj4Fg

    Thanks

    Hello,

    The code is only for the /?lang=en search term. Please try this filter instead:

    <?php
    // Rank Math - removing error in Google Console
    add_filter( 'rank_math/json_ld/search_url', function( $url ) {
    if ( 'en' === ICL_LANGUAGE_CODE ) {
    return 'https://www.gentlewench.com/?post_type=products&s={search_term_string}&lang=zh-hans';
    }
    if ( 'zh-hans' === ICL_LANGUAGE_CODE ) {
    return 'https://www.gentlewench.com/?post_type=products&s={search_term_string}&lang=zh-hans';
    }
    return $url;
    } );

    Once done, clear your website’s cache and check again using the rich results test.

    I hope that helps.

    Thank you.

    Great, thank you

    Hello,

    Glad that helped.

    Please feel free to reach out to us again in case you need any other assistance.

    We are here to help.

    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)

The ticket ‘Custom query parameter not defined in target URL’ is closed to new replies.