(Revised answer, based on the code in question and this)
After the discussion, I realized that:
-
You should replace the
post__not_in
withtag
; i.e. use'tag' => $tag
.You should also understand that
post__not_in
should be an array of post IDs and not tag/category slugs, names, etc. And if you don’t pass an array, then you’d get the error in question, even in WordPress version 5.2.4. 🙂 -
You should use
get_query_var( 'tag' )
to get the selected tag (slug). -
And remove the
category__in
.
So your WP_Query
code would look like so:
$args = array( // then the query args
'posts_per_page' => 5, // you should use posts_per_page and not showposts
'post_type' => 'post',
'tag' => get_query_var( 'tag' )
);
$sticky_query = new WP_Query( $args );
Additionally:
-
The
select
code (for letting users pick a tag):<?php $tag = get_query_var( 'tag' ); ?> <select name="formal" class="city-choice" onchange="handleSelect(this)" data-action="<?php echo esc_url( add_query_arg( 'tag', '%tag%' ) ); ?>"> <option value="">Select a tag</option> <option value="usa" <?php selected( $tag, 'usa' ); ?>>Usa</option> <option value="italy" <?php selected( $tag, 'italy' ); ?>>Italy</option> </select>
-
The JavaScript code (for submitting the tag selected via the above
select
):<script type="text/javascript"> function handleSelect(elm) { window.location = elm.dataset.action.replace( '%tag%', elm.value ); } </script>