• I’m working on a site for a client that contains several blogs. Since they are all authored by the same person I’ve simply set each blog up with its own category and have all links to that need to point the blog point to that category.

    The only issue I’ve run in to is search. I’d like users to be able to search one of the blogs (one category) without having the results from other categories displaying.

    I’ve read some posts around here about using a TDO plugin or using query_posts but I wasn’t able to find anything specific.

    So, my question is: How do you restrict search to results from one category?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Look around a bit for a plugin. I believe this one makes a search page where users can, for example, chose one category. The plugin is ages old though, I don’t know if there’s a 3.0 version.
    https://www.zirona.com/software/wordpress-advanced-search/

    Thread Starter Will White

    (@willpcg)

    Thanks for the link.

    I was hoping it would be a simple addition to the form action or the search.php function. It’s looking like its more complex than that. I’ll look for a plugin.

    I’m answering the same question on two forums ?? The Dutch guy found this German version of the plugin.
    https://www.zirona.com/erweiterte-suche/

    Thread Starter Will White

    (@willpcg)

    Ugh I can’t seem to make the plugin do what I want it to do.

    Its offering an advanced search – the option for users to choose which category they want among other options.

    I don’t want users to have a choice. If they put anything in the search field I want it restricted to that category.

    Thread Starter Will White

    (@willpcg)

    I’m going to test a few more tricks – if it doesn’t work its back to the plugin library.

    Maybe it’s a better idea to make a “network” so that each blog just has it’s own piece of the database and its own searchform.

    Thread Starter Will White

    (@willpcg)

    I thought about doing that – using WordPress MU or something.

    Part of the reason I opted for the single setup with multiple categories is because one of the categories is going to hold definitions for a dictionary-style area on the site. (The website is for a psychologist that would like to have basic terms she refers to throughout her blogs listed).

    So the game-plan was to create a series of posts all containing definitions – and keep them in the “dictionary” category – then add a search field that limits the results to posts within the dictionary category.

    The fact she could log in once to update her to other blogs was an added benefit of setting things up this way.

    Thread Starter Will White

    (@willpcg)

    Just an update for anyone else looking for this:

    Step 1: Create an alternate searchform.php – mine was called ‘dictionary.php’

    Step 2: Call the alternate search form where you’d like the restricted search to be located on your page using PHP.

    Step 3: Update the “action” url in your html form to the directory you’d like the search to be performed in.

    EG: To search in the category named “Example” you would change the action url of the form to https://mysite.com/category/example

    <form role="search" method="get" id="searchform" action="https://www.mysite.com/category/dictionary">
            <label class="screen-reader-text" for="s">Search for:</label>
            <input value="Search" name="s" id="s" type="text">
            <input id="searchsubmit" value="Search" type="submit">
    </form>
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Search within a Category’ is closed to new replies.