• Resolved Nic727

    (@nic727)


    Hi,

    I’m trying to translate my main website title, but I’m unable to do it. I’ve create custom settings for my page.

    Code used in functions.php

    function aurora_customize_register( $wp_customize ) {
        // Do stuff with $wp_customize, the WP_Customize_Manager object.
    
        /* Pinegrow generated Customizer Controls Begin */
        $pgwp_sanitize = function_exists('pgwp_sanitize_placeholder') ? 'pgwp_sanitize_placeholder' : null;
    
        $wp_customize->add_section( 'aurora_default_cs', array('title' => 'Personnalisation de la page d\'accueil'));
    
        $wp_customize->add_setting( 'home_img', array(
            'type' => 'theme_mod',
            'sanitize_callback' => $pgwp_sanitize
        ));
    
        $wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, 'home_img', array(
            'label' => __( 'Image de l\'accueil', 'aurora' ),
            'type' => 'media',
            'mime_type' => 'image',
            'section' => 'aurora_default_cs'
        ) ) );
    
        $wp_customize->add_setting( 'home_vid', array(
            'type' => 'theme_mod',
            'sanitize_callback' => $pgwp_sanitize
        ));
        $wp_customize->add_control( new WP_Customize_Media_Control( $wp_customize, 'home_vid', array(
            'label' => __( 'Home video', 'aurora' ),
            'type' => 'media',
            'mime_type' => 'video',
            'section' => 'aurora_default_cs'
        ) ) );
        function allow_video_upload( $existing_mimes ) {
            $existing_mimes['mp4'] = 'video/mp4';
            $existing_mimes['mov'] = 'video/quicktime';
            // Ajoutez d'autres extensions de fichiers vidéo si nécessaire
            return $existing_mimes;
         }
         add_filter( 'mime_types', 'allow_video_upload' );
        
         $wp_customize->add_setting( 'main_title', array(
            'type' => 'theme_mod',
            'default' => '',
            'sanitize_callback' => $pgwp_sanitize
        ));
    
        $wp_customize->add_control( 'main_title', array(
            'label' => __( 'Titre principal', 'aurora' ),
            'type' => 'text',
            'section' => 'aurora_default_cs'
        ));
    
        $wp_customize->add_setting( 'sub_title', array(
            'type' => 'theme_mod',
            'default' => '',
            'sanitize_callback' => $pgwp_sanitize
        ));
    
        $wp_customize->add_control( 'sub_title', array(
            'label' => __( 'Sous-titre', 'aurora' ),
            'type' => 'text',
            'section' => 'aurora_default_cs'
        ));
    
    
    }
    function register_theme_strings() {
        pll_register_string('aurora', get_theme_mod('main_title'), 'aurora', true);
        pll_register_string('aurora', get_theme_mod('sub_title'), 'aurora', true);
    }
    add_action('init', 'register_theme_strings');

    And in my front-page.php

    $main_title = get_theme_mod( 'main_title' );
    $sub_title = get_theme_mod( 'sub_title' );
    
     <div class="home-title"> 
                <h1><?php pll_e($main_title); ?></h1> 
                <h2><?php pll_e($sub_title); ?></h2> 
            </div>             

    Any idea how it can recognize that?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Doesn’t recognize string added via custom setting’ is closed to new replies.