Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form role="search" method="get" id="searchform"
- class="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
- <div>
- <label class="screen-reader-text" for="s"><?php _x( 'Search for:', 'label' ); ?></label>
- <input type="text" value="<?php echo get_search_query(); ?>" name="s" id="s" />
- <input type="submit" id="searchsubmit"
- value="<?php echo esc_attr_x( 'Search', 'submit button' ); ?>" />
- </div>
- </form>
- function filter_search_post_type($query) {
- if ( $query->is_search && ! is_admin() && ! empty($_GET['search_post_type']) ) {
- $query->set( 'post_type', array($_GET['search_post_type']) );
- }
- }
- return $query;
- }
- add_filter('pre_get_posts','filter_search_post_type');
- <?php get_search_form(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement