Can you please refer to the following tutorial and let me know if you need any assistance? So that we will help you accordingly.
Reference tutorial: https://structured-data-for-wp.com/docs/article/how-to-enable-sitelinks-search-box-in-schema/
I have done this. It only works for the homepage but not for posts.
Google is not allowed to set it on any other pages, So we only add it on the homepage. Therefore add this markup only to the homepage, not to any other pages. Here below are some references regarding it, Please go through it once.
References:
https://prnt.sc/wL94OJ3xwYre
https://developers.google.com/search/docs/advanced/structured-data/sitelinks-searchbox
Yoast SEO Plugin adds it to all pages. You can check any website using the yoast plugin they have site link search box on all pages.