I have nhl news website and I create custom taxonomy for each season (ex 2014-15)
function wptp_register_taxonomy() {
register_taxonomy( 'season', 'post',
array(
'labels' => array(
'name' => 'Seasons',
'singular_name' => 'Season',
'search_items' => 'Search Season',
'all_items' => 'All Season',
'edit_item' => 'Edit Season',
'update_item' => 'Update',
'add_new_item' => 'Add New Season',
'new_item_name' => 'New Season',
'menu_name' => 'Seasons',
),
'hierarchical' => true,
'sort' => true,
'args' => array( 'orderby' => 'term_order' ),
'rewrite' => array( 'slug' => 'season' ),
'show_admin_column' => true
)
);
}
add_action( 'init', 'wptp_register_taxonomy' );
add_filter('pre_get_posts','season_archive');
function better_editions_archive( $query ) {
if ( $query->is_tax( 'season' ) && $query->is_main_query() ) {
$query->set( 'post_type', array( 'post' ) );
$query->set( 'tax_query',
array(
'relation' => 'OR',
array(
'taxonomy' => 'season',
'field' => 'slug',
'terms' => 'intl',
'operator' => 'IN'
)
)
);
}
return $query;
}
EX When I want to get for 2013-2014 posts:
http://localhost/nhl/news/?season=20132014
Now what I want is when I go to the category news without taxonomy
http://localhost/nhl/news/
to show only current season posts for ex 20142015 without using custom taxonomy slug
Thank you