Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility with “Relevanssi” Plugin #436

Open
VinodKKumar opened this issue Dec 12, 2020 · 6 comments
Open

Incompatibility with “Relevanssi” Plugin #436

VinodKKumar opened this issue Dec 12, 2020 · 6 comments

Comments

@VinodKKumar
Copy link

[catlist search=”The Cake is a lie”]

This feature does not work with “Relevanssi” Plugin- plugin for website search. It shows empty.

After deactivating this, the { search=”The Cake is a lie” } shows results.

Relevanssi is much better than WordPress default search function in terms of results, so this cant be avoided.

Kindly make necessary changes/ suggestions/ solutions for this.

@klemens-st
Copy link
Collaborator

Should pin this feature request for a future update.

@VinodKKumar
Copy link
Author

Thanks for your reply. Hope that this feature will be implemented soon.

@klemens-st
Copy link
Collaborator

@picandocodigo
Copy link
Owner

@zymeth25 just getting back into WordPress and starting to remember how this works...

If I understand correctly, we use the WP_Query object when calling query_posts($args) here, which sets the WP_Query we want to $wp_query, is this right? (looking at this code after so long feels like it's the first time 😆 ). So we would do relevanssi_do_query( $wp_query ); inside the confitional that checks if the plugin function exists:

query_posts($args);
global $wp_query;

if(function_exists('relevanssi_action_links')){
  relevanssi_do_query($wp_query);
}

I can write this and test it locally, but it'll be hard to add tests for integrations with other plugins.

@klemens-st
Copy link
Collaborator

klemens-st commented Mar 4, 2021

If I understand correctly, we use the WP_Query object when calling query_posts($args) here, which sets the WP_Query we want to $wp_query, is this right?

Yes, 'query_posts' actually also makes it the main query. This is fine if someone wants to use LCP to generate a whole custom archive page, or a custom blog page, but should be avoided in all other cases e.g. when it's just a secondary list in a widget or part of a larger post/page. This is why the problem in #445 exists.

This also means that your solution would work but according to the docs linked in the support thread above it would run the query twice, being somewhat resource inefficient.

So perhaps the best way is to add your change and then I'll try to think of something as per #445 to improve post querying.

It's possible to write tests for this but a bit too complicated and unnecessary I think. Maybe later ;)

@klemens-st
Copy link
Collaborator

If it doesn't work with query_posts then we will first have to deal with #445 and resolve this issue later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants