How can i share WP_Query between multiple functions?
If you want to reduce code duplication, then extract the code into its own function, e.g.: function get_xyz_query_args( ) : array { return array(‘post_type’ => ‘accomodation’, ‘posts_per_page’ => 4, ‘meta_query’ => array(‘key’ => ‘accomodation_type’, ‘value’ => get_query_var(‘accomodation_type’))); } …. $args = get_xyz_query_args(); $q = new WP_Query( $args ); However, there is very little performance to … Read more