WordPress.org

Ready to get started?Download WordPress

Forums

Relevanssi - A Better Search
Custom Post types (10 posts)

  1. whiteorb
    Member
    Posted 3 years ago #

    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!

  2. Mikko Saari
    Member
    Plugin Author

    Posted 3 years ago #

    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?

  3. whiteorb
    Member
    Posted 3 years ago #

    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.

  4. Mikko Saari
    Member
    Plugin Author

    Posted 3 years ago #

    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...

  5. whiteorb
    Member
    Posted 3 years ago #

    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'";
    			}
  6. Jonathan Wold
    Member
    Posted 2 years ago #

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

  7. Mikko Saari
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  8. Mikko Saari
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  9. Mikko Saari
    Member
    Plugin Author

    Posted 2 years ago #

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

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

  10. whiteorb
    Member
    Posted 2 years ago #

    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"

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags