I am working on WordPress website in which I am using multilingual functionality. and I am using POLYLANG plugin.
I have a situation in which , I have to remove
language code from URL , for SPECIFIC PAGES only
this is how URL generates : site_url/nl/page_slug
and I want to create URL like this site_url/page_slug
So , for some of the pages I want to remove nl
How do I make it happen ?
I have used the below filter and the issue was resolved.
function filter_pll_check_canonical_url( $redirect_url, $language ) {
$redirect_url = str_replace('nl', '', $redirect_url);
}
add_filter( 'pll_check_canonical_url', 'filter_pll_check_canonical_url', 10, 2 );
I am checking with the current URL, if the current URL has a language code so replaced language code with a blank space and URL will seem to like:-
site_url/nl/page_slug => site_url/page_slug