WordPress.org

Ready to get started?Download WordPress

Forums

Search Everything
Not working for custom taxonomies (7 posts)

  1. Lumpysimon
    Member
    Posted 3 years ago #

    Hi

    I have defined a custom post type called Artwork, with several non-hierarchical custom taxonomies (tags) assigned to it.

    Search Everything doesn't seem to be searching these taxonomies, even with the option set to Yes.

    E.g. I have several Artworks tagged 'Sea', but if I search for Sea it only returns Artworks that have Sea in the title or content.

    Many thanks
    Simon

  2. sarahd
    Member
    Posted 3 years ago #

    Just chiming in that I've had this issue too. Looks like it is the combo of a custom post type and a custom taxonomy. A quick hack to search-everything.php shows you can customize the post type and the taxonomy to make a search work (lines 750-754).

  3. sarahd
    Member
    Posted 3 years ago #

    Here's my edited bit of code that seems to work for specific custom post types and custom taxonomies in case it is helpful (starts at line 748):

    // if we're searching custom taxonomies
    if ( $this->options['se_use_tax_search'] )
    {
    $post_taxonomies = get_object_taxonomies('posts');
    $gallery_taxonomies = get_object_taxonomies('gallery-posts');
    $nonprofit_taxonomies = get_object_taxonomies('nonprofit-posts');
    $all_taxonomies = array_merge($post_taxonomies, $gallery_taxonomies, $nonprofit_taxonomies);
    foreach ($all_taxonomies as $taxonomy)
    {
    if ($taxonomy == 'post_tag' || $taxonomy == 'category' || $taxonomy == 'gallery_tags'  || $taxonomy == 'issue_categories' || $taxonomy == 'region' || $taxonomy == 'country' || $taxonomy == 'nonprofit_tags' || $taxonomy == 'np_region' || $taxonomy == 'np_country' || $taxonomy == 'np_issue' )
    continue;
    $on[] = "ttax.taxonomy = '".addslashes($taxonomy)."'";
    }
    }
  4. Justin Sternberg
    Member
    Posted 3 years ago #

    same problem! i'll try this method.

  5. Justin Sternberg
    Member
    Posted 3 years ago #

    i replaced the existing code in the plugin with the code you provided, and then replaced the custom post types, and custom taxonomies you have listed with my own... no luck!

    Why is so difficult to search custom taxonomies??

  6. kidradio
    Member
    Posted 3 years ago #

    This has been driving we crazy for a while as well, although I made a tweak that seems to get it working. The above code didn't work for me either, but editing those same lines from search-everything.php like this did:

    if ( $this->options['se_use_tax_search'] )
    {
    $all_taxonomies = get_object_taxonomies('review');
    foreach ($all_taxonomies as $taxonomy)
    {
    if ($taxonomy == 'post_tag' || $taxonomy == 'category')
    continue;
    $on[] = "ttax.taxonomy = '".addslashes($taxonomy)."'";
    }
    }

    All I did was change the line:
    $all_taxonomies = get_object_taxonomies('post');
    to this
    $all_taxonomies = get_object_taxonomies('review');

    Where 'review' is a registered post-type of mine, and now it searches all of my different post types as well (not sure why). Quite sure this isn't the best way to go about it, but it works for now!

  7. Lumpysimon
    Member
    Posted 3 years ago #

    i've moved to relevanssi (http://wordpress.org/extend/plugins/relevanssi) - problem sorted!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic