Elementor Pro has a widget called "Search form". This is suitable for the attractive design of search forms. Unfortunately, this search form is limited in its functionality.
Question: How can I modify the Elementor search form to restrict the search to certain content types (e.g. search only for Posts, Pages, Products, FAQ, ...)?
Answer / Solution:
- Give the widget a unique ID, e.g. mnc_search_posts
- Insert the following code into functions.php:
add_action( 'elementor_pro/search_form/after_input', function( \ElementorPro\Modules\ThemeElements\Widgets\Search_Form $form ) { if($form->get_settings()['_element_id'] ?? null === 'mnc_search_posts') { echo ''; } }, 10, 1 );