Forums

Search selected custom fields in a category (5 posts)

  1. colourblindsl
    Member
    Posted 4 months ago #

    Good day all,
    I'm hoping to find out how to search only selected custom fields in a particular category, the form below is what I'm using to search this particular cat.:

    <form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
    		<label for="s" class="assistive-text"><?php _e( 'Search', 'twentyeleven' ); ?></label>
    		<input type="text" class="field" name="s" id="s"  placeholder="<?php esc_attr_e( 'Search catalogue', 'twentyeleven' ); ?>" />
         <!--   <input type="hidden" value="21" name="cat" id="scat" />-->
    
    		<input type="submit" class="submit" name="submit" id="searchsubmit" value="<?php esc_attr_e( 'Go', 'twentyeleven' ); ?>" />
    	</form>

    How can I specify particular custom fields within this cat??

    Thanks in advance,
    SL chai

  2. dkotter
    Member
    Posted 4 months ago #

    The code you posted above is the actual search box, which is typically searchform.php. The page you'll need to modify is search.php, which is the page that renders the search results.

    On search.php, there should be a normal WordPress loop. This loop will show any search results from that originated from the search form. So you'll basically need to modify that loop to only show results from your specific category.

  3. colourblindsl
    Member
    Posted 4 months ago #

    Thanks dkotter,
    You couldn't elaborate a little more, could you, I'm a noob programmer here :-(
    sl chai

  4. dkotter
    Member
    Posted 4 months ago #

    It really depends on exactly what you want to do and how you have things set up.

    But I did find this plugin that sounds like it should do what you want, and you won't have to worry about coding anything.

  5. colourblindsl
    Member
    Posted 4 months ago #

    thanks, I'll have a look at the plugin.

Reply

You must log in to post.

About this Topic