• Resolved clawduda

    (@clawduda)


    Hi,
    I was looking in the jsonld code Yoast created for my site and I noticed that the reference for the sitelink searchbox points to domain.com/?s={search_term_string}

    However, my site is a store so my main search is for products.

    The default ?s={search_term_string} shows results in a bad way. Is there a way to force the code to change to the correct format which would be in my case ?s={search_term_string}&post_type=product&product_cat=0 ?

    Thank you in advance

Viewing 5 replies - 1 through 5 (of 5 total)
  • HI @clawduda,

    You can change the search URL in the SearchAction schema using the wpseo_json_ld_search_url filter. We have more information about it in the Yoast Schema developer documentation and in the Yoast SEO code on GitHub.

    As an alternative, you can disable this schema piece using the disable_wpseo_json_ld_search filter. You can find examples in this guide: Disabling graph pieces by filter.

    Thread Starter clawduda

    (@clawduda)

    Hi @priscillamc ,
    thanks for this.
    Any chance you can help me out with the correct functions code to use ? I tried to create it myself bu it seems i keep failing and i am not sure where i am wrong.

    Thank you!

    Thread Starter clawduda

    (@clawduda)

    hi again,

    i found the code i needed to use on another website

    // Yoast - change ld+json search url
    function crunchify_change_json_ld_search_url() {
    	return trailingslashit( home_url() ) . '?s={search_term_string}&post_type=product&product_cat=0';
    }
    add_filter( 'wpseo_json_ld_search_url', 'crunchify_change_json_ld_search_url' );

    i will leave it here in case anyone else is trying to achieve the same thing

    Plugin Support devnihil

    (@devnihil)

    @clawduda Thanks for posting the solution you found. Please let us know if you have any additional questions or if we can be of further assistance.

    Plugin Support devnihil

    (@devnihil)

    We are going ahead and marking this issue as resolved due to inactivity. If you require any further assistance please create a new issue.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Sitelink searchbox code for woocommerce sites’ is closed to new replies.