Saltar al contenido Saltar a la barra lateral

Este hilo está resuelto. Aquí tienes una descripción del problema y la solución.

Problem:
If you're experiencing issues where the CSS breaks on translated pages of your website, it might be related to how global sections are rendered within your theme. Specifically, the Code Snippets plugin may not be loading your theme's CSS correctly for the second language.
Solution:
We recommend using a Child Theme instead of the Code Snippets plugin. You can add the following snippet to the functions.php file of your Child Theme to address some of the CSS issues:

add_action('init', function() {
    // Hook location to output the global section
    $location_hook = 'nectar_hook_global_section_footer';
 
    add_action($location_hook, function() use ($location_hook) {
 
        // Detect current language
        $current_lang = apply_filters( 'wpml_current_language', null );
 
        // Default section ID (Spanish)
        $global_section_id = '24759-2';
 
        // Use translated section ID for English
        if ( $current_lang === 'en' ) {
            $global_section_id = '26378';
        }
 
        // Default category ID (Spanish)
        $category_id = 47;
 
        // Use translated category ID for English
        if ( $current_lang === 'en' ) {
            $category_id = 156;
        }
 
        // Output the section only if we're on the correct category archive
        if ( is_product_category( $category_id ) ) {
            Nectar_Global_Sections_Render::get_instance()->output_global_section($global_section_id, $location_hook);
        }
 
    });
});

However, if disabling the Code Snippets plugin resolves all issues, we suggest not using it and instead managing code through the Child Theme as shown above.

Please note that this solution might be outdated or not applicable to your specific case. We highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket.

Este es el foro de soporte técnico de WPML, el plugin multilingüe de WordPress.

Todas las personas pueden leerlo pero solo los clientes de WPML pueden ingresar comentarios. El equipo de WPML responde en los foros 6 días a la semana, 22 horas por día.

Este tema contiene 1 respuestas, tiene 0 voces.

Última actualización por jobR hace 1 semana, 6 días.

Asistido por: Andreas W..

Autor Publicaciones
diciembre 4, 2025 a las 4:13 pm

jobR

Hi I have pages that in the version translated the css is brake

diciembre 4, 2025 a las 8:06 pm #17636082

Andreas W.
Partidario de WPML desde 12/2018

Idiomas: Inglés (English ) Español (Español ) Alemán (Deutsch )

Zona horaria: America/Lima (GMT-05:00)

If I revise the translated Global Section, the translations seem to work as expected:
enlace oculto

The issue seems to occur on the way these sections are rendered inside the theme, here by using the Code Snippet plugin, which is not loading the theme's CSS in the second language.

It might be advisable to instead use the Child Theme:

I am now loading the following snippet through the functions.php file of the Child Theme, and it solves some of the CSS issues:

add_action('init', function() {
    // Hook location to output the global section
    $location_hook = 'nectar_hook_global_section_footer';

    add_action($location_hook, function() use ($location_hook) {

        // Detect current language
        $current_lang = apply_filters( 'wpml_current_language', null );

        // Default section ID (Spanish)
        $global_section_id = '24759-2';

        // Use translated section ID for English
        if ( $current_lang === 'en' ) {
            $global_section_id = '26378';
        }

        // Default category ID (Spanish)
        $category_id = 47;

        // Use translated category ID for English
        if ( $current_lang === 'en' ) {
            $category_id = 156;
        }

        // Output the section only if we're on the correct category archive
        if ( is_product_category( $category_id ) ) {
            Nectar_Global_Sections_Render::get_instance()->output_global_section($global_section_id, $location_hook);
        }

    });
});

Still, the testimonials will not show up on the translated archive, the image gallery is not appearing correclty, and generally the translated products are not showing up on the archive (not related to Global section content).

Surprisingly, all issues disappear once I disable the Code Snippets plugin.

I would suggest not using the plugin and instead loading the snippets inside the hook that I added to the functions.php file.

diciembre 5, 2025 a las 4:16 am #17636624

jobR

Thanks Andreas for all your work, I will apply your solution