• ragulka

    (@ragulka)


    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?

Viewing 1 replies (of 1 total)
  • Thread Starter ragulka

    (@ragulka)

    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!

Viewing 1 replies (of 1 total)
  • The topic ‘Search for Categories’ is closed to new replies.