WordPress Advanced Search query custom fields

WordPress Advanced Search query custom fields

In this Post We Will Explain About is WordPress Advanced Search query custom fields With Example and Demo.Welcome on Live24u.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to How to Create Advanced Search Form in WordPress for Custom Post TypesExample

In this post we will show you Best way to implement advanced search forms for WordPress-powered sites, hear for Creating a search form for custom fields – WordPresswith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Also Read :   PHP Inheritance - Multilevel and Multiple Inheritance in PHP

You can download source code and Demo from below link.




Step 1 : query_search.php

First of all we need to do is open simple your query_search.php file or wherever your search here form is stored. and Then add the simple following fields here inside the form source code:

<!-- Advanced Search For articles -->
<input type="hidden" name="post_type[]" value="articles" />
<!-- Advanced Search For post -->
<input type="hidden" name="post_type[]" value="post" />
<!-- Advanced Search For videos -->
<input type="hidden" name="post_type[]" value="videos" /> 
<!-- Advanced Search For books -->
<input type="hidden" name="post_type[]" value="books" />  

Step 2 : search.php

Next open your simple search.php file and and here paste the following simple codes above your for or any loop content, therefore your list of users can see the all options at the top menu bar.

Also Read :   http POST method request and response in angularjs

<form role="search" method="get" id="query_search" 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'); ?>

<!-- Advanced Search For books -->
<input type="checkbox" name="post_type[]" value="books" <?php if (in_array('books', $query_types)) { echo 'checked="checked"'; } ?> /><label>Search Books</label>

<!-- Advanced Search For videos -->
<input type="checkbox" name="post_type[]" value="videos" <?php if (in_array('videos', $query_types)) { echo 'checked="checked"'; } ?> /><label>Search Videos</label>

<!-- Advanced Search For articles -->    
<input type="checkbox" name="post_type[]" value="articles" <?php if (in_array('articles', $query_types)) { echo 'checked="checked"'; } ?> /><label>Search Articles</label>

<!-- Advanced Search For post -->
<input type="checkbox" name="post_type[]" value="post" <?php if (in_array('post', $query_types)) { echo 'checked="checked"'; } ?> /><label>Search Blog</label>

<!-- Simple Submit Button-->   
<input type="submit" id="searchsubmit" value="Advanced Search" />
</form>

You can download source code and Demo from below link.





Example

Also Read :   Automatic counter using AngularJS - Angular Timer

I hope you have Got What is Creating a search form for custom fields – WordPress And how it works.I would Like to have FeadBack From My Blog(live24u.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(live24u.com) Are Most Always Welcome.

   

Add a Comment

Your email address will not be published.