Hot answers tagged

3

Something like this might work: $args = array( 'post_type' => 'post', 'tax_query' => array( array( 'taxonomy' => 'your_custom_taxonomy', 'operator' => 'EXISTS' ), ), ); $query = new WP_Query( $args ); You are basically asking for any post assigned to any term within your_custom_taxonomy.


2

You could set up a custom post type with custom taxonomies and then allow people to filter the results or do a search. Failing that, perhaps an event plugin would help. It depends on how much coding you want to do or if you want to try and find a plug and play solution.


2

In general you can't. ID numbers given at one site might be already used at another.


1

Note that if you have the post slug, you don't need the additional taxonomy query to find that post, so it makes sense to drop the expensive taxonomy query in core in that case. Otherwise you could try instead the post_name__in parameter: [ 'post_name__in' => [ '<postslug>' ], 'tax_query' => [ [ 'taxonomy' ...


1

If you want to change the order of an already existing query, you shouldn't create a new WP_Query object but instead use pre_get_posts to alter the existing query, which prevents multiple queries running unnecessarily. From the pre_get_posts docs: This hook is called after the query variable object is created, but before the actual query is run. ...



Only top voted, non community-wiki answers of a minimum length are eligible