Sure, that should be possible. Can you describe the issue a little more? Are you trying to exclude the “current page” the shortcode is being displayed on? Or does each shortcode usage need to exclude an arbitrary post_id ?
Each shortcode usage needs to exclude an arbitrary post_id is EXACTLY what I’m going for.
Thanks for getting back so quickly Jonathan!
Mike
This isn’t ideal from a UX perspective, but it should work
Where “test” is your query’s slug, and “1234” is the post ID to exclude.
[query slug="test" args="post__not_in%5B%5D=1234"]
What’s going on there is a few things:
1. The shortcode attribute “args” allows you to pass in additional WP_Query arguments that override any existing values on the query.
2. But when dealing with arrays (like the post__not_in argument requires), the string has to be a urlencoded. Otherwise it will break the shortcode.
Here it is not-urlencoded for reference:
[query slug="test" args="post__not_in[]=1234"]
Notice those brackets next to “post__not_in”? Those will break the shortcode.
The url encoding for left bracket [ is %5B, and the url encoding for right bracket ] is %5D. Thus our result [query slug="test" args="post__not_in%5B%5D=1234"].
Hope that makes sense, let me know if you run into issues. This is the first time I’ve attempted this approach w/ urlencoding the brackets.
Worked like a charm! Thanks so much Jonathan!!
I love this plugin!!!