Wordpress Advanced Search query custom fields

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 Pakainfo.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!.

  How to get CSS class Name Property using Jquery

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.

  PHP Arrays Example Tutorial For Beginners From Scratch

<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" />


  Redirect page after delay using Jquery

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(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

Leave a Reply

Notify of