Created
March 15, 2018 19:53
-
-
Save certainlyakey/065f9f2476d33a9224bb6d4f80d082f0 to your computer and use it in GitHub Desktop.
A fix for Polylang language switcher links pointing at front page on post type archives of untranslated post types (Wordpress + Polylang)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function polylang_languageswitcher_untranslated_pts_archives_links_fix( $url, $slug ) { | |
if ( is_post_type_archive( array('event', 'career') ) ) { | |
$url = add_query_arg( | |
array( | |
'post_type' => get_post_type(), | |
), | |
pll_home_url( $slug ) | |
); | |
} | |
return $url; | |
} | |
add_filter( 'pll_the_language_link', 'polylang_languageswitcher_untranslated_pts_archives_links_fix', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment