Skip to content

Instantly share code, notes, and snippets.

@certainlyakey
Created March 15, 2018 19:53
Show Gist options
  • Save certainlyakey/065f9f2476d33a9224bb6d4f80d082f0 to your computer and use it in GitHub Desktop.
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)
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