Skip Navigation

Displaying View search results on separate page always displays in default language

Open

Symptoms

If you have a multilingual site and you split a custom search View so that the search form displays on one page and the results on another, if you initiate the search on a secondary language page, the results will display on the default language page instead of persisting in the secondary language.

This only happens if you are using the WPML Sticky Links plugin.

Workaround

You can add the following code snippet (at Toolset > Settings > Custom Code) to prevent Sticky Links from modifying URLs for certain pages.

In this example, if we display our search results on a page whose slug (in a secondary language) is ‘search-results’ then we can add the ‘search-results’ slug to a blacklist of URLs Sticky Links should ignore, like so:


add_filter( 'wpml_sl_blacklist_requests', 'fix_wpml_sl_blacklist_requests', 10, 2 );

function fix_wpml_sl_blacklist_requests( $blacklist, $sitepress ) {
$blacklist[] = 'search-results';
return $blacklist;
}

Leave
a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>