WordPress.org

Forums

Ajaxy Live Search
[resolved] Filter Out Categories (4 posts)

  1. robgundling
    Member
    Posted 3 years ago #

    It looks like you wrote your own search to return these results. Is there a way to filter out categories in the returned results?

    http://wordpress.org/extend/plugins/ajaxy-search-form/

  2. robgundling
    Member
    Posted 3 years ago #

    Ok.. it's a technical solution that involves hardcoding the plugin, but it works until the next revision. I really like the output of this plugin, but HAD to hide a couple categories due to my customized WP categories.

    You'll need to know your category IDs..

    Edit the plugin sf.php file and around line 861 you'll see before that

    foreach($results as $result)
    
    			{

    My categories to hide were 10 and 13, so my code that I inserted at that point is:

    $catoutofloop = get_the_category($result->ID);
    $catID = ($catoutofloop[0]->term_id );
    if ( ($catID != "10") && ($catID != "13") )
    {

    You'll then need to close your if statement, so find around line 950 at this point

    $posts[] = $pst; 
    
    					}

    And add one more closing backet after that, so the updated code will end:

    $posts[] = $pst; 
    
    					}
    				}
    
    			}
    
    		}
    
    		return $posts;

    I hope this helps someone. The developer told me this will be in the next release.

  3. smythk
    Member
    Posted 2 years ago #

    Great plugin!
    Can I exclude all search results except for posts and pages?

  4. Naji Amer
    Member
    Plugin Author

    Posted 2 years ago #

    Guys, all you need is in the settings of the plugin, you can exclude and include any category, post, tag etc..., please check the settings robgundling before touching the code, it is already there

    regards

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Ajaxy Live Search
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic