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.