• Resolved casper99

    (@casper99)


    Hi,

    i am using WordPress 6.3.1 with “WP file download” Version 5.9.0 and Relevanssi free Version 4.21.

    When the “WP file download” plugin is activated, no content from own CPT are being displayed in the search results.

    I am using Standard Gutenberg Editor.

    When i deactive “WP file download” everything works as expected.

    I already opened a support ticket at Joomunited (WP file download).
    Maybe, anyone also having the problem here.

    Best regards

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

    (@msaari)

    Check that WP File Download does not set a post type restriction in the search.

    If you can’t adjust this from WP File Download, you can always override it:

    add_filter( 'relevanssi_modify_wp_query', function( $query ) {
      $query->set( 'post_types', array( 'post', 'page', 'your_cpt', 'other_post_type' );
      return $query;
    } );
    Thread Starter casper99

    (@casper99)

    Thank you Mikko, this really works.

    Do i manually have to list my CPT?

    In the backend, relevanssi can detect all CPT. Can’t relevanssi set the filter by itself, so i don’t have to manually list the CPT again (as i already checked them in the backend)?

    Plugin Author Mikko Saari

    (@msaari)

    Well, none of this would be necessary, if WP File Download wouldn’t set its own post type restriction… so any complaints are best directed that way ?? Without WPFD, this would just work, as there would be no post type restrictions in place, and the search would be based on the post types listed in the Relevanssi indexing settings.

    Relevanssi can’t set this filter, because Relevanssi can’t tell which post types you want to include in the search. Yes, most of the time, all indexed post types are required, but not always, and Relevanssi can’t tell.

    Thread Starter casper99

    (@casper99)

    OK. Thanks again. You’re right.
    I’ll give the support a hint.

    I thought that Relevanssi could set the filter based on the CPT options set in the backend of relevanssi. There i define, which CPT should be searched or not.

    Plugin Author Mikko Saari

    (@msaari)

    That’s how it works in vast majority of times when another plugin doesn’t want to set the post type.

    Thread Starter casper99

    (@casper99)

    OK. The solution works, but I think it is a bit complicated.

    Unfortunately, the “WP file download” developer also only have a solution in code, like yours.

    I share your opinion, that it’s not the fault of Relevanssi. But the error can occur, even with other plugins, which overwrite the search loop and many users (like me) are confused and need to manually search for the solution.

    The only thing, I can’t understand. I already checked all the CPT in the relevanssi backend, which should be searched. Can’t you implement the over code “add_filter( ‘relevanssi_modify_wp_query’…” in the relevanssi core-code and take the checked fields from the backend?

    So the backend options are automatically adopted and the enduser doesn’t have to do it twice, even in code.

    Thanks!!!

    • This reply was modified 1 year, 6 months ago by casper99.
    Plugin Author Mikko Saari

    (@msaari)

    A four-line code snippet is not complicated. It’s the standard way to deal with this in WordPress; you should get used to it, as using filter hooks like this is how many WordPress features are used.

    The way Relevanssi is set up works for more than 99% of cases without any modifications required. The cases where another plugin messes with the search parameters are very rare. You have bumped into one of these extremely rare cases with WP File Download.

    The checked fields need to be in the backend. How could Relevanssi otherwise tell which post types the user wants to include in the search? In normal cases – almost always – there are no post type restrictions in the search, and the checked fields in the backend control what is in the search and what is not. Nothing else is required from the user; everything just works.

    Also, I can’t just automatically force the search to include all checked post types. Yes, in many cases users want to include all indexed post types in the search, but it’s also very common to have multiple search forms on the site, all searching different combinations of post type. Forcing the search to use all indexed post types would break this very important functionality.

    So, trust me: Relevanssi is built in the most meaningful and useful way, and you’ve just run into a fringe case where another plugin interferes with how things should work.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘No results from CPT when “WP file download” is installed’ is closed to new replies.