How to Add a WordPress Custom Search Form for Custom Post Types. This will add a couple of new features to the WordPress admin panel on the left. This is where you control styling input for the search field.
Add the following code to the functions.php file of your current activated WordPress theme.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /** * Custom Search for Library. */ function fwm_search_library($template) { global $wp_query; $post_type = get_query_var('post_type'); if( $wp_query->is_search && $post_type == 'library' ) { //redirect to archive-search.php return locate_template('search-library.php'); } return $template; } add_filter('template_include', 'fwm_search_library'); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.