612-293-8629 [email protected]

Recently, I needed a search form that searched and resulted in posts from a specific category. I solved it by adding a hidden input field to my searchform.php file as follows:

<form class="search" role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
    <div>
        <input type="text" value="Search Staff Pages" name="s" id="s" onclick='javascript: this.value = ""' />
        <input type="image" src="<?php bloginfo('stylesheet_directory'); ?>/img/search-sidebar-background-button.png" id="searchsubmit">
        <input type="hidden" name="cat" id="cat" value="21" /> 
    </div>
</form>

Note, in the code above, I am searching posts in the category whose id is 21.

Pretty nifty, eh?

Thanks to WP Explorer for the idea.

PHONE, EMAIL, TEXT

We love to communicate: phone, email, text, Facebook, Twitter, LinkedIn, you name it.

LOCATIONS

PAYMENTS ACCEPTED

Call Now

Enroll in Our Free Beginner WordPress Class by Email

Never feel powerless in WordPress again!  Become a WordPress superstar for free in only minutes a day!

Our Beginner WordPress Email Class is delivered to your inbox!

Learn More 

You Have Successfully Enrolled! Prepare For Amazing!