Wordpress: Can these 2 functions be combined into one?

Viewed 21

I'd like to combine/refactor (if possible) these 2 functions into 1 since their scope is narrowly focused to one tax on my site. Purpose is to redirect links to a taxonomy term to the first (oldest) post in that category in the most efficient way possible:

function redirect_series() {
  if (is_tax('series')) {
    global $post;
        wp_safe_redirect(get_permalink($post->ID));
    die;
  }
}
add_action('template_redirect','redirect_series');

function order_by_date_callback ( $query ) {
    if (($query->is_main_query()) && (is_tax('series'))) {
        $query->set( 'orderby', 'date' );
        $query->set( 'order', 'ASC' );
    }
}
add_action( 'pre_get_posts', 'order_by_date_callback' );
0 Answers
Related