Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // How to Create Advanced Search Form in WordPress for Custom Post Types
- <form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
- <input type="text" name="s" id="s" <?php if(is_search()) { ?>value="<?php the_search_query(); ?>" <?php } else { ?>value="Enter keywords …" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"<?php } ?> /><br />
- <?php $query_types = get_query_var('post_type'); ?>
- <input type="checkbox" name="post_type[]" value="movies" <?php if (array('movies', $query_types)) { echo 'checked="checked"'; } ?> /><label>movies</label>
- <!-- here value="movies" and array(movies) is my post type change your own-->
- <input type="checkbox" name="post_type[]" value="movies" <?php if (array('movies', $query_types)) { echo 'checked="checked"'; } ?> /><label>movies</label>
- <!-- here value="movies" and array(movies) is my post type change your own-->
- <input type="submit" id="searchsubmit" value="Search" />
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement