admin管理员组

文章数量:1134081

I'm trying to minimally hook (via a plugin) into the search form generated by the default search block and add a target="_blank" to open the results in a new tab. I'd much prefer to do this via PHP and not JavaScript. The get_search_form filter and outright overriding a piece of the template won't necessarily work because I can't assume the search experience hasn't been edited, only that the default core search block is being used and that it has some kind of search form. Is there some obvious use of has_block or get_block_template or some other newer function that I'm overlooking?

I'm trying to minimally hook (via a plugin) into the search form generated by the default search block and add a target="_blank" to open the results in a new tab. I'd much prefer to do this via PHP and not JavaScript. The get_search_form filter and outright overriding a piece of the template won't necessarily work because I can't assume the search experience hasn't been edited, only that the default core search block is being used and that it has some kind of search form. Is there some obvious use of has_block or get_block_template or some other newer function that I'm overlooking?

Share Improve this question asked Sep 29, 2022 at 19:53 jshwlkrjshwlkr 5221 gold badge6 silver badges24 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

The render_block filter might provide a solution. I say 'might' because i have not tested and the search "form" element may not be accessible via the filter.

Wordpress Render Block filter

本文标签: Adding attributes to the core search block form