WordPress.org

Ready to get started?Download WordPress

Forums

Search for Categories (2 posts)

  1. ragulka
    Member
    Posted 4 years ago #

    Is there a plugin or maybe another way to be able to search for categories in WordPress? I'm using long descriptions for my categories with the Rich Text Tags, Categories, and Taxonomies plugin.
    And I want users to be able to find catgeories as well, not only posts.
    So is there a way to search for categories and list them on the search results page?

  2. ragulka
    Member
    Posted 4 years ago #

    I have found one solution.

    I needed to use the Category Search plugin by Vladimir Prelovac.

    Then, I had to tweak it a little, namely, change this:

    if (strpos(strtolower($cat->name),strtolower($search_string))!== false)
    			{
    				$name=attribute_escape( $cat->name);
    				$link=get_category_link( $cat->term_id );
    				$desc=$category->description;
    				$output.=$before_list.'<a href="'.$link.'">'.$name.'</a>'.$desc.$after_list;
    				$count++;
    			}

    to this:

    if (strpos(strtolower($cat->name),strtolower($search_string))!== false || strpos(strtolower($cat->description),strtolower($search_string))!== false)
    			{
    				$name=attribute_escape( $cat->name);
    				$link=get_category_link( $cat->term_id );
    				$desc=$category->description;
    				$output.=$before_list.'<a href="'.$link.'">'.$name.'</a>'.$desc.$after_list;
    				$count++;
    			}

    And that's it!

Topic Closed

This topic has been closed to new replies.

About this Topic