Clean up WordPress code that repeats
To expand on the answer by Global: Paste this into your theme’s functions.php: function get_stations_query( $terms ) { //create new query object $query = new WP_Query( array( ‘post_type’ => ‘stations’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘genres’, ‘field’ => ‘name’, ‘terms’ => $terms … Read more