I don’t know if you use a classic or block theme. Introducing PHP in a block theme is rather convoluted. Classic theme templates are PHP based and are easier to introduce custom PHP code into. Even with the more accessible (regarding PHP) classic templates, you’ll need to determine where the search link should go in relation to other page content. Once you find a likely spot, you could do something like:
<a href="<?php echo get_site_url( null, '?s=Foo'); ?>">Search for "Foo"</a>
Be mindful of existing PHP code that’s demarcated with <?php ?>
. The above suggestion belongs outside of any existing PHP code, it should be placed where normal HTML already exists. If you need to add it within existing PHP code, break out of it with ?>
, insert the above code, then restart PHP afterwards with <?php
. You cannot break out just anywhere, do it after a PHP terminal ;
If you use a block theme, I believe custom PHP needs to be introduced via a pattern.