Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
stefano1

The use of pre_get_post brakes admin columns filters or searches

Dear all,

I have an issue regarding the searches and queries on a specific Custom Post Type made by specific groups of users.
Those groups, visualize thru a pre_get_post a specific subset of the entire dataset (in this case filtering a specific value depending by the group, group A filter city A, group B shows post only from city B and so on).
Unfortunately the use of the pre_get reset entirely any kind of query of filter made by the user.
There is any advice or solution that could help me solve this issue.
thank you

Stefano

2 years, 10 months ago
Stefan van den Dungen Gronovius
Developer

Do I understand correctly that your own filter for pre_get_posts causes our filtering and sorting not to work?
I don’t know your code, but it is good to know that you use this hook to alter the query and assume that some hooks have already altered the query. You could try to play with the priority of the hook to see what happens with the query when you use different priorities. You could even try to add another hook on a high priority to see the final query. The plugin ‘Query Monitor’ could also help you with analyzing the query since it will record every fired query. You can search for the main query easily to see that query that is fired to retrieve the records.

2 years, 10 months ago
stefano1

Hi Stefan,
thank you for your help, and sorry for about the confused question.
Yes, my pre_get_post completely brakes admin cols query.
I will try first to use the priority (I actually didn’t think about it, thank you) and install than the Query Monitor.
Than if I can’t figure it out how to solve I will extrapolate my code here to help understand my issue.
thank you again

Stefano

2 years, 10 months ago

You must be logged in to reply to this topic.