WordPress.org

Support

Support » Plugins and Hacks » [Plugin: Relevanssi – A Better Search] Custom Post types

[Plugin: Relevanssi – A Better Search] Custom Post types

  • I have quite a number of custom post types and Relevanssi doesn’t seem to be indexing any of them. I set it to everything or all post types and they simply don’t return. If I place the post type in the “Custom post types to index:” field it returns no results at all. Any help would be appreciated.

    Excellent plugin Mikko!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Mikko Saari

    @msaari

    Do the custom post types have exclude_from_search set or not? Are they public? Is “Respect exclude_from_search for custom post types” set or not? Which version of Relevanssi?

    It’s the newest version of Relevanssi, how do I verify the other two options? What should I have it set at. The plugin I’m using for custom fields and posts is More Types and More Fields.

    Plugin Author Mikko Saari

    @msaari

    The post types should have ‘exclude_search’ set to false and ‘public’ set to true.

    I’ve only ever added post types by manual coding, so I don’t know about any plugins.

    I’ll have to do some checks on my test systems to see if everything’s working, but it should be…

    I did a full system search and this is what was set in relevanssi.php.

    if (!$post_type && get_option('relevanssi_respect_exclude') == 'on') {
    		if (function_exists('get_post_types')) {
    			$post_type = implode(',', get_post_types(array('exclude_from_search' => false)));
    		}
    	}

    More Types gives you the option to exclude from search. All were set “no” by default.

    case "public":
    			if (function_exists('get_post_types')) {
    				$custom_types = implode(',', get_post_types(array('exclude_from_search' => false)));
    				$allow_custom_types = false;
    			}

    On line 2392 of query.php I found this. It was set to true by default but I’m unsure if that would have an effect.

    if ( $q['post_status'] == 'any' ) {
    				foreach ( get_post_stati( array('exclude_from_search' => true) ) as $status )
    					$e_status[] = "$wpdb->posts.post_status <> '$status'";
    			}

    Exact same issue here. I’ll keep an eye on this thread for further feedback and be available to test accordingly.

    Plugin Author Mikko Saari

    @msaari

    Here’s something you can do to help me test this: please check if Relevanssi is indexing the custom post entries. It’s easy to check: add a unique word to one of the custom post entries and see if the word appears in the Relevanssi database (_relevanssi).

    Right now it seems Relevanssi is indexing the custom posts properly, but not finding the terms when searching.

    Plugin Author Mikko Saari

    @msaari

    Ok, figured it out. The problem was caused by More Types plugin, actually. It sets ‘exclude_from_search’ to ‘0’, but Relevanssi is testing for false (which is what the WordPress default post types have).

    For a quick fix, uncheck “Respect exclude_from_search” option and the custom type entries should appear in search. I’m fixing this in the next version.

    If somebody has an account on the More Types plugin forums, I’d appreciate if somebody could post about this here, more standard behaviour from More Types plugin would be preferred.

    Plugin Author Mikko Saari

    @msaari

    …and version 2.8.1, fixing this, is out now.

    If you like Relevanssi, please consider upgrading to Relevanssi Premium.

    Excellent Mikko, it worked great! I’ll absolutely look into buying the premium version.

    The group that builds “more plugins” is extremely poor at assisting users in their forum or even responding at all but I’d be happy to let them know it should be “false”

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: Relevanssi – A Better Search] Custom Post types’ is closed to new replies.