For the complete documentation index, see llms.txt. This page is also available as Markdown.

Hide button on excluded page

Since the version 3.5 of Weglot plugin, the button is visible even is the page is excluded. Here is how to hide it on excluded page

Since version 3.5, the language button stays visible even on pages you excluded from translation. For example, if you excluded /fr/contact, the button still shows on both /contact and /fr/contact.

To hide the button on excluded pages:

// Add this using the "Code Snippets" plugin or directly in functions.php
add_filter( 'weglot_button_html', 'weglot_button_hide', 10, 3 );
function weglot_button_hide( $html, $classes ) {
    $show_button = weglot_get_service( 'Request_Url_Service_Weglot' )->is_eligible_url( weglot_get_current_full_url() );
    if ( ! $show_button ) {
        return '';
    }
    return $html;
}

Last updated