-
Notifications
You must be signed in to change notification settings - Fork 261
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
pre_get_posts in admin #559
Comments
Hi, |
Ok : I found 2 solutions With You can use instead of |
If anyone still has problems with this the above solution is correct but when in admin you don't need to call the static method again, simply hook your function on "parse_query" with priority less than 20 since on 20 P2P parses query by default. If you're getting WordPress database error Operand should contain 1 column(s) error it means your arguments are being hooked into the distributed connections query as well and you simply need to check for specific post type before setting the query args.
|
Hello,
First of all thank you @scribu for your plugin. I've been using it for years now and it's still very useful.
I'm running into a little problem trying to limit admin posts list with p2p arguments.
Basically, I'm using the
pre_get_posts
hook in admin, I'm on the main query and I try to add some P2P query args like so:Unfortunately, it has no effect on the posts list even if I see my params in the global $wp_query variable.
If in this same
pre_get_posts
hook I initiate a second WP_Query with the same P2P params, I do receive the posts I want and I can use them with:$query->set('post__in', $my_posts);
But it means that I need to run 2 queries.
Is it something you've already experimented and do you have a chance to have a look at it?
Thanks again.
Ben
The text was updated successfully, but these errors were encountered: