• Hi i use this function

    add_filter( 'default_content', 'my_editor_content', 10, 2 );
    function my_editor_content( $content, $post ) {
        switch( $post->post_type ) {
            case 'corso':
                $content = '';
            break;
            case 'olea':
                $content = '';
            break;
            default:
                $content = "<br><br><br>
    			[tab name='CARATTERISTICHE TECNICHE']
    	[/tab]
    [tab name='FUNZIONI AVANZATE']
    
    [/tab]
    [tab name='IMMAGINI CLINICHE']
    
    [/tab]
    	[end_tabset]
    			";
            break;
        }
    
        return $content;
    }

    to add defaut text to the post… BUT i have two languages so if the new post is in English i need to show that text in english.
    in front end with
    <?php echo "lingua: ".pll_current_language(slug);?>
    i retrieve the current post language
    but in backend how can i retrieve the language of the new post?

    bye
    Maurizio

    https://ww.wp.xz.cn/plugins/polylang/

Viewing 1 replies (of 1 total)
  • Thread Starter Maurizio Spicuglia

    (@nextart)

    with this function
    $val = $_GET['new_lang'];
    retrieve the slug of languages, then the function became:

    add_filter( 'default_content', 'my_editor_content', 10, 2 );
    
    function my_editor_content( $content, $post ) {
          $val = $_GET['new_lang'];
          if ($val=='en'){
       		switch( $post->post_type ) {
    
            case 'corso':
                $content = '';
            break;
            case 'olea':
                $content = '';
            break;
            default:
                $content = "<br><br><br>
    			[tab name='SPECIFICATIONS']
    			[/tab]
    			[tab name='ADVANCED FEATURES']
    			[/tab]
    			[tab name='CLINICAL IMAGES']
    			[/tab]
    			[end_tabset]
    			";
            break;
    		}
    	} else {
    		switch( $post->post_type ) {
            case 'corso':
                $content = '';
            break;
            case 'olea':
                $content = '';
            break;
            default:
                $content = "<br><br><br>
    			[tab name='CARATTERISTICHE TECNICHE']
    			[/tab]
    			[tab name='FUNZIONI AVANZATE']
    			[/tab]
    			[tab name='IMMAGINI CLINICHE']
    			[/tab]
    			[end_tabset]
    			";
            break;
        }
    }
        return $content;
    }

    bye Maurizio

Viewing 1 replies (of 1 total)

The topic ‘retrieve post language in back end’ is closed to new replies.