Get lanuage in template_redirect event
-
Hello. I have an installation of WP and Polylang with ENG/GR languages.
I am using the snippet below to redirect from a archive (taxonomy client does not have polylang enabled) to single page, when archive has only 1 element. (post have two languages)function stf_redirect_to_post(){
global $wp_query;
if( is_tax(‘client’ ) && $wp_query->post_count == 1 ){
the_post();
$post_url = get_permalink(pll_get_post(get_the_ID()));
wp_redirect( $post_url );
}
} add_action(‘template_redirect’, ‘stf_redirect_to_post’);Though, it always redirect to the default language. Is there sometihng I miss?
- The topic ‘Get lanuage in template_redirect event’ is closed to new replies.