Fire Studios

Archive

Contact

Categories

  • Coding
    • CSS
    • HTML/Javascript
    • PHP
  • Design
  • Freebies
  • General
  • Internet
  • Interviews
  • Plugins
  • Podcasts
  • Reviews
  • Screencasts
  • Tutorial
  • Weekday Tips
  • Wordpress

Podcast

Search By Category – WP Plugin

Search By Category – WP Plugin

Search by Category allows your visitor to select which category they want to search your blog inside of. This allows visitors to find the exact article they're looking for and helps increase viewer loyalty.

Where to Download

Download Search By Category

How to use

  • Download and install the plugin
  • Configure the options
  • Edit your Theme file to include this code where ever you want the search form:
<?php if(function_exists('sbc')){
	sbc();
} else { ?>
	...your standard form code here...
<?php } ?>

or if you want to use it in a post or page:

[sbc]

Change Log

1.2
- Included Shortcode: [sbc]

1.1
- Added security fixes
- Removed some excess code

1.0.0
- Default text
- Custom styling

Beta 3
- Search Text
- Exclude Child categories
- search box auto empties and refills if nothing entered

Beta 2
- First complete working version
- Hide Empty
- Focus
- Exclude Categories

Beta 1
- First working version
- Category exclustion from drop-down list isn't functional

Alpha 1
- All functions are present but independent

Reader's Thoughts

  • Hon tap

    So cool. This is a good feature. Thank you very much.

  • Duane

    I think this will really help my readers find things. I use a three column format and the text in the categories box is a bit too long (Categorie is all I can get to show). Is there a way to change that font size? I figure it is pulling it from my template but I thought there might be an over ride I can do by modifying the code of the plugin?

  • Fire G

    @Duane: Im sorry to say that SBC was just not meant to be pushed into that small of an area. Even with lowering the font size to it's smallest readable level, the whole word wasn't visible in Firefox and IE.

    I suggest copying this CSS into your stylesheet and disable the SBC setting in WP-Admin:


    form#sbc-search {clear: both; display: block;}
    form#sbc-search * {margin: 0px; display: block;}

    form#sbc-search input#s {background: #f5f5f5; border: 1px solid #bbbbbb; padding: 4px 10px; width: 80%; margin: 0px auto 10px;}

    form#sbc-search select#cat {background: #fbfbfb url(arrow.png) 88% 50% no-repeat; height: 30px; width: 99%; border: 1px solid #bbbbbb; padding: 4px 20px; -khtml-appearance: none; /* fix default safai styling */ border-radius: 15px; -webkit-border-radius: 15px; -moz-border-radius: 15px;}

    form#sbc-search select#cat option {padding: 2px 4px;}

    form#sbc-search input#sbc-submit {height: 30px; width: 40%; margin-top: 10px; border: 1px solid #bbbbbb; float: right; border-radius: 15px; -webkit-border-radius: 15px; -moz-border-radius: 15px;}

  • Duane

    Thanks Fire G for taking the time to respond. I tried this but couldn't find the place the disable SBC setting (although if you meant to uncheck the box 'Use the SBC Form styling', I did that). So the problem persisted. In the process of working in the CSS stylesheet I noticed my sidebar 2 was set at 170px wide, while sidebar one was set at 175px. So, I changed the sidebar 2 width voila, it worked. Now the whole word 'Categories' is visible as well as the little down arrow. That also made the elements at the right side of my page line up better. Thanks!

  • Germán

    The link to download is wrong. "http" has two "h" ;)

  • Flex Guy

    Great post… good suggestions…thanks!

  • elmalak

    Hi,
    I have just downloaded and installed your plugin and I think it's a great one.

    I just noticed a bug that I thought would be nice to tell you about.
    I installed the plugin into a page and when I search for something it displays the correct results.

    However, when there is no result to show it displays" No results found. Try another search"
    And below that I get the regular search form and not the Search by Category form!

    Is there a way to prevent that from happening?

    thanks,

  • Fire G

    Thanks for the kind words.

    what you'll need to do is look in your theme's index.php for the search box that you mentioned and just replace that code with the SBC code. You should also do the same with all of your other theme files.

  • DoZ

    I think could be nice the ability to select more than one single category...
    Don't you?

  • GadgetGuru

    Is there search by tags option?

  • Fire G

    @GadgetGuru: No since the drop-down would be Gigantic and the default WordPress search already searches based on category (but orders it based on publish date. There's a plugin to change that already).

  • John

    Hi,

    Currently I have this plugin displaying on only certain category archives. I'd like to make is so that the default search is to search the current category, and another option is to search all categories.

    Can you suggest a way to do this?

    Thanks!

  • Fire G

    @John, That's actually a great feature I could add in. When the next release goes live (will be soon) you'll be able to do it then.

  • obseque

    thank's a lot for your work, it's the plu ing i search... so is there any way to hide category list ? (i use a template page and i don't want the user can search other thing than only one category) ... thank's for your respond

  • Paul

    Using WP 2.8.3 and when I use the shortcode on a page the search form forces itself to the top of the page above where I want it to display. Any idea how I can make it show up where I want it?

    Also, does this plugin search post/page content, tags, comments... or just titles?

    Thanks!

  • Paul

    Also, just noticed a couple other bugs.

    One, I cannot disable any categories. I click the checkbox and choose save and then the checkbox is blank again. Any ideas?

    Two, Disabling the style doesn't seem to change anything.

    Once again I'm using 2.8.3 with the default wordpress theme.

    Thanks,
    If I can get these bugs ironed out it will be perfect!!!

  • Paul

    Now this if I try to exclude categories and click save:

    Warning: mysql_real_escape_string() expects parameter 1 to be string, array given in /home/mylocald/public_html/wp-content/plugins/search-by-category/search-by-category.php on line 107

  • Ron

    Great plugin! Its works fine on the front end.

    The backend is displaying the same error Paul stated above. It saves the categories to exclude but it cant be altered.

    Is there any fix for this?

    Thanks.

  • Fire G

    Thanks guys, i'll look into it.

  • Paul

    Your latest update fixed the error and now it will allow me to select categories to exclude from the dropdown. One more question though, how can I make this plugin include tags in its search?

    Thanks, awesome plugin by the way!

  • Fire G

    WordPress search is already configured to search based on tags. All this plugin does is remove results that aren't in the selected category.

    Glad you enjoy the plugin.

  • Paul

    I created a post and added a tag (my zip code) to it. Then I searched for that zip code and nothing showed up. Is there a setting in wordpress that I don't know about that needs to be set?

    Also the [sbc] tag still forces the search form to the to of my post...any ideas how I can make it show up half way down the post where I would like to have it?

    Thanks again!

  • Laurent

    Hi! Thanks for this plugin. i am using it and it's working fine but I'm searching how to replace the drop-down menu by a list of categories (selection using radio buttons). Anyone who can help on adding this feature? Can we simply modify something in the plugins code? Thanks for your help. Laurent.

  • Nothing

    Great plugin! and thanks for this.
    but replace the drop-down by check boxes is good.

  • badcat

    Is there a way to allow searching of the text used in the Blogroll (Linklist) and Link Categories? Another plugin perhaps or maybe this can be altered?

  • jeremy

    thanks for your plugin !

    please, how to configure this for search only in title ?

  • Fire G

    @Jeremy: You can use the "Search Everything" plugin to customize search results.

  • jeremy

    @Fire G: Thanks, but the "Search Eveything" plugin do not allow to search only in title or i did not found this options...

  • Eddie

    Hi there,

    Would it be possible to have some settings on this plugin where i can search under a parent category(pg) for its child categories(cg).

    i.e> Price (pg) to show 1,000-5,000(cg) and 5,000-10,000(cg)

    and another one to show something else

    i.e> Year (pg) to show 1990-2000(cg) and 2000-2010(cg)

    showing at the same time?

    In conclusion, making settings to customize the drop down menu's with specific pg and cg's giving [sbc1], [sbc2]...etc

  • Fire G

    @Eddie: Neat Idea, I may put it in the next version. But currently, no, there's no way of doing that.

  • Eddie

    Would you consider a handsome paypal donation for a working beta version within a week or two? I cant find anything else that does this, and i sure aint sure how to code it, but i gotta deadline in 3 weeks.

  • Fire G

    @Eddie: Shoot me an email to 'fireg@fire-studios.com' with your proposition and a clearer explanation of what you want.

  • martis

    Is it possible to generate a link to search inside a specific category?

    I want to search for a specific tag inside a specific category, and then list the results.

    Example
    LINK_TO_CLICK_ON -> Search results with all posts tagged with "audi" inside the "cars" category.

    Of course I can create all those pages manually with the wp_query_posts() function, but this would take up months to do it for all possible combinations :)

    I just want to use search.php or archive.php etc.

  • JT

    Hello
    I am very new beginner and tryed to install this plugin. But I dont know where in theme to make this change
    1.
    4. ...your standard form code here...
    5.
    Can you explane for me more where I should paste this in theme file?
    I tryed but that was feil.
    Thanks in advance

  • Luis Rivera

    I see that here http://net.tutsplus.com/articles/news/building-a-custom-search-by-category-wordpress-plugin-new-plus-tutorial/ i think you just rip that.

  • Fire G

    @Luis: I wrote that article.

  • dany

    i dont understand where i put the code ?

    01.
    04. ...your standard form code here...
    05.

  • Fire G

    @dany: Just replace "...your standard form code here..." with the search form code you used before SBC so that if you delete or deactivate the plugin, your site doesn't lose its search box.

  • Dennis

    First of all, thank you for creating such a great plugin. I've been searching and searching for something like this for quite some time.

    I just had a quick question.. is it possible to remove certain categories from being searched from within the 'In All Categories' selection?

    I like how you can manually exclude categories from the drop-down, however, those categories are still searched when a visitor selects 'in all categories'...

  • Fire G

    @Dennis: That's a good idea. I'll push it in a new release.

  • Dennis

    @Fire G

    Thanks for acknowledging my post! I'll keep my eyes open for the next release.

    You can see how it functions on my site here: http://www.redcanary.ca

  • Mike

    Hello,

    Sorry I'm not much of a coder and can't seem to figure out where to paste the code:

    1.
    4. ...your standard form code here...
    5.

    Which CSS file do I install this code in? I tried SearchForm.php and it didn't work, just made # symbols next to all of my search boxes. Also, is it possible to only display the Search by Category options on certain pages or categories?

    Thanks!

    Mike

  • Mark

    @Fire G - was wondering if you might be able to help? I'm running into a small issue when I get my search results page. Any thoughts?

    For some reason, when I do a search, I am getting the appropriate posts back but I am getting 4 blank small-posts added to the bottom.

    I have my site turned off at this time, but here is the code that is popping up when I inspect it with Firebug. (This is one instance, but it repeats 4 times).

    Here is the code I'm using:

    Anyone have any ideas? Thanks in advance.

    Mark

  • Fire G

    @Mark: Your code seems to have gotten filtered so I'm unable to help. You can use services like http://pastebin.com to handle the code.

  • Mark

    Okay, so no obviously not - sorry, I posted the embed code from pastebin.com, but it looks like it removed it again. Let's try this way.

    Firebug code for search results:

    http://pastebin.com/embed_js.php?i=jJdMKSgp

    Code for the search bar itself:

    http://pastebin.com/embed_js.php?i=nCRVZrUj

    Hopefully this works....

    Thanks,

    Mark

  • Fire G

    @Mark: The problem looks to be in your index.php file. There are several HTML errors, but I'm unable to fully identify the problem since I can't view the source or see the erroneous page.

  • wparena

    This is really helpful plugin, although I have to make lot of changes to get the required result but still excellent work

  • Walter

    Hi,

    can i choose the "Drag & Drop" Field by Categories also as "Checkboxes"?

  • Fire G

    @Walter: I have no idea what you're asking.

  • JFLO

    Is there an update that will work with the latest WordPress 3.2.1?

  • Steve

    Hi,

    Trying to use this plugin on a project and we can get it to display, using the [sbc] shortcode,
    where want no matter what we do.. it just forces itself (how, I don't know) to the top of the page, breaking out of any div or container we put it in.

    Can you tell us how to position this on a page please?

  • Steve

    sorry typo, I meant we can NOT get the shortcode to display on the page where we want it to (we can and have styled it..)

  • Fire G

    @Steve: Short codes only work in the WP Loop (posts, pages, etc...), so it'd have to be in the content for that to work. You should 99% of the time be using the sbc() function.

  • Dave

    Hi man. I'm having a bit of issues with the plugin. Other widgets I try to place under it seem to overlap it.

    Check it out on my site: http://www.aresmen.com password is [removed] (one word)

  • Fire G

    @Dave, it's just a CSS issue on your theme, it's not clear-floating the widgets, so the browser doesn't understand it's full height. Not SBC's fault or issue.

  • Dave

    I don't suppose there's a simple fix for that, huh.

  • Saddie

    Hi!
    Is there any way of excluding page results?
    I just want the posts to be found

  • Justin Mason

    Is there any way to run multiple instances of this plugin?

  • Fire G

    @Justin: You can call the function multiple times via the php or shortcode version.

  • Jill

    Thank you for your excellent work with this plugin. It doesn't appear that anyone else here had trouble with the 'exclude from results' option. If you visit http://blog.aerotechmotioncontrol.com/browse-faqs/ and perform an unfiltered search for ".net", you will see the first result is "Engineers’ Choice Award Finalist," which is in Category ID=10, which is one of the categories that I have excluded in SBC admin. None of the Category IDs I entered for exclusion are actually being excluded. Could there be a conflict with another plulgin to cause this?

    My 'exclude from search' string looks like this: 114,19,10,15,53,7,95,7,9,121,123,126,122,124,125,11,3,4,12,1

  • Fire G

    @Jill: I'll look into it later today or tomorrow when I have time.

  • evi

    Hi! It works just fine for me, thank you! My issue is in appearrence... please take a look here http://www.makeupproject.gr/page-pedia/ the search bar appears also in header... Could you healp me out?

  • evi

    You can ignore my previous comment, I just put the code at the sidebar and problem solved! Thanks again!

  • Paolo

    Hi!
    Thanks for he plugin!
    I would like to search in a certain category (i decide) if no other is specified.
    How can I do that?
    Thank you
    Paolo

  • Jill

    Hello @FireG, have you had a chance to look into the "exclude from results" issue I posted above? We hope to go live with our site on Jan 1st. Thanks again!

  • Fire G

    Yes. I'm pushing an update to the WP plugin repo in a few minutes that will fix the issue.

  • Jill

    Thank you for the plugin update. Unfortunately this did not resolve the issue. I have upgraded, cleared the site cache as well as the browser cache, but a search for ".net" still displays results from categories in the "excluded category" list.

    Steps to Reproduce:

    1. Visit http://blog.aerotechmotioncontrol.com/browse-faqs/
    2. Perform an unfiltered search for ".net"
    3. The first result is "Engineers’ Choice Award Finalist," (cat ID=10)
    4. Confirm the 'exclude from search' string: 114,19,10,15,53,7,95,7,9,121,123,126,122,124,125,11,3,4,12,1

  • Fire G

    @Jill: It should be working. The only other possibility is that your settings stored in the DB are not stored properly. Deactivate SBC, delete "SBC_settings" from the wp_options table, re-activate SBC and re-do your settings.

    It works on me so this about all I can think of that could be the problem on your version.

  • Kijek

    Hello

    Thanks for great plugin :) But i have a question. Now if I want to search something I have to select post category and write something in search box. But if I want to just display all posts from one category (without writing) how I can do this?

  • stav

    In the current version 2.0.2 of the plugin, what is the value of $cat_id on about line 246:

    ´if(!$only_cat){
    ...
    $settings = array('show_option_all' => $focus,
    ...
    'selected' => $cat_id,´

    In version 2.0.1 it looked like:

    ´if(!$only_cat){
    $cat_id=$_GET['cat'];
    ...
    $settings = array('show_option_all' => $focus,
    ...
    'selected' => $cat_id,´

    FYI: version 2.0.1 works great, 2.0.2 does not work, sorry i can't provide more details yet.

  • Fire G

    @Stav: You're right. I never touched that line in the previous updates, but it did get removed.

    I pushed a new version 2.0.3 with the fix.

  • Pete

    Hi Fire G,

    Great plugin that you can see I'm using on my site, thanks!

    The issue I have is that searches retrieve content that is on Pages which do not have Categories. Is it possible to stop Pages from being searched?

    Thanks,

    Pete

  • Ed

    I have this setup on FoundersQuotes.com and it's works just fine, but it's missing ONE category (George Washington). The ID for that category is 1. It doesn't matter what I change in the options, the category just won't show.

    Any ideas?

  • Ed

    Never mind. I just deactivated and reactivated. The category shows.

    Thanks!

  • Andrés

    Hi, great plugin, I congratulate you and ask you a question.
    How I can translate the word "search" for the word "search"

    Thank you.

  • Andrés

    Hi, great plugin, I congratulate you and ask you a question.
    How I can translate the word "search" button by the word "buscar" in Spanish?

    Thank you.

  • Fire G

    @Andres: open the plugin and edit the line "<input type="submit" id="sbc-submit" value="Search" />" (line 272) and change "Search" to whatever.

  • Atelier

    Great plugin, but an awesome feature would be to be able to remove the default 'Search in all categories' option entirely, and select a primary category for users to select. This would allow users to be able to install [SBC] for searching a particular section of a website, and another for another section of the website. Being able to remove the drop-down altogether in this way would be excellent. I will happily pay for you to add in this functionality - drop me an email! Best wishes, Atelier.

Your Thoughts?

 

This is that small text that tells you not to steal our stuff, but we don't really care too much.