• Resolved plumedaure2016

    (@plumedaure2016)


    Hello ! I would need some help please.
    I just got the Revolution Slider which is a plugin that allows me to have a slider on my blog. I wanna have it on the home page so I put a code like <?php putRevSlider(“Plumedaure”) ?> on index.php which works well.

    Ok, problem is my blog is in two languages FR and EN (see plumedaure.com). And I would like to have two different silders that I call on the index.php file.

    I’ve tried something like

    if( is_language( ‘en’ ) ){
    <?php putRevSlider(“Plumedaure”) ?>
    ;
    }

    but I can’t get the code to work. Any idea of what code to insert for Polylang/WP to understand the request?

    Thanks in advance for your help which will be precious!

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

    [ No bumping please. ]

Viewing 8 replies - 1 through 8 (of 8 total)
  • You can use polylang function pll_current_language() to get the current language.

    Thread Starter plumedaure2016

    (@plumedaure2016)

    Hello thanks so much I’ll check this.
    Let you know if I still struggled once I’ve tried the code πŸ™‚
    Enjoy your day!! and thanks again

    Thread Starter plumedaure2016

    (@plumedaure2016)

    Hello I’m very very lost. I’m not so good in HTML, sorry…

    What I want is to put a different Revolution Slider for my FR and EN subdomains. (You can see my blog is plumedaure.com).

    —-

    For now I just have <?php putRevSlider(“Plumedaure”) ?> which is a French Slider on index.php but the problem is I want to call a different one for english (called : <?php putRevSlider(“Plumedaureenglish”) ?> )

    What is the code I have to use please? This is my index.php code below :

    [ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

    <?php get_header(); ?>
    
    <?php putRevSlider("Plumedaure") ?>
    
    <div class="row">
    	<div class="col-md-8">
    		<main id="content" class="entries-classic" role="main" itemprop="mainContentOfPage" itemscope="itemscope" itemtype="http://schema.org/Blog">
    
    			<div class="row">
    				<div class="col-md-12">
    
    					<?php if( is_search() ): ?>
    						<?php
    							global $wp_query;
    
    							$found = $wp_query->found_posts;
    							$none  = esc_html__( 'No results found. Please broaden your terms and search again.', 'olsen-light' );
    							$one   = esc_html__( 'Just one result found. We either nailed it, or you might want to broaden your terms and search again.', 'olsen-light' );
    							$many  = esc_html( sprintf( _n( '%d result found.', '%d results found.', $found, 'olsen-light' ), $found ) );
    						?>
    						<article class="entry">
    							<h2 class="entry-title">
    								<?php esc_html_e( 'Search results' , 'olsen-light' ); ?>
    							</h2>
    
    							<div class="entry-content" itemprop="text">
    								<p><?php olsen_light_e_inflect( $found, $none, $one, $many ); ?></p>
    								<?php if ( $found < 2 ) {
    									get_search_form();
    								} ?>
    							</div>
    
    							<div class="entry-utils group"></div>
    						</article>
    					<?php endif; ?>
    
    					<?php while ( have_posts() ) : the_post(); ?>
    						<?php get_template_part( 'content', 'entry' ); ?>
    					<?php endwhile; ?>
    
    				</div>
    			</div>
    
    			<?php olsen_light_pagination(); ?>
    		</main>
    	</div>
    
    	<div class="col-md-4">
    		<?php get_sidebar(); ?>
    	</div>
    
    </div><!-- /row -->
    
    <?php get_footer(); ?>

    —–

    If you could help you would be my HERO of all times ! Thanks so much

    ok, try this

    <?php
      get_header();
      $curlang = pll_current_language();
      if ($curlang=='en') {
        putRevSlider("Plumedaureenglish");
      }
      elseif ($curlang=='fr') {
         putRevSlider("Plumedaure");
      }
      else { //slider for other languages, default to french
         putRevSlider("Plumedaure");
      }
    ?>

    the rest of the code is the same. Try this and tell me how is it going.
    Cheers…

    Thread Starter plumedaure2016

    (@plumedaure2016)

    OH MY GOD you are a STAR ! Thanks sooo much ! It works ! You can check it by yourself πŸ™‚

    Plumedaure.com

    Super happy ! Any review I can let somewhere for you? πŸ™‚

    Hi…it is good to hear that it works for you. I see your blog and a nice one too.

    Cheers…

    Thread Starter plumedaure2016

    (@plumedaure2016)

    Thanks a lot πŸ™‚

    Hey!

    This topic might be dead, but I am currently experiencing some flaws here.

    I am trying to create the code as following (explained newbie style)

    if curlang = 1 { do_shortcode ([myshortcode1]) } ifelse curlang = 2 { do_shortcode ([myshortcode2]) }

    Im not an expert in PHP, so I can’t create my own code.
    I’ve used code above, resulting in a blank page.

    I’m using insert pages plugin to implement pages into the main-page (since my customers can then edit the page them self).

    Code:

    <?php $curlang = pll_current_language();
    						if ($curlang=='nl') {
    							do_shortcode( "[insert page='welkom' display='content']" );
    											}
    						elseif ($curlang=='de') {
    							do_shortcode( "[insert page='wilkommen' display='content']" );
    												}
    				  else { //If language is different then NL or DE
    							do_shortcode("[insert page='welkom' display='content']");
    						}
    				?>

    Can you help/explain why its not working for me?
    Page is wp.energizedesigns.nl

    Thanks

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Get language in index.php –> what code to use?’ is closed to new replies.