• Hi-
    This is What I have in the header. But when I press Spanish this part stay in english? Is any solution….

    <?php if(isset($mts_options['mts_trending_articles'])) { if($mts_options['mts_trending_articles'] == '1' && $mts_options['mts_trending_articles'] != '') { ?>
    			<div class="trending-articles">
    				<ul>
    					<li class="firstlink"><?php _e('Start Here','mythemeshop'); ?>:</li>
    					<?php $i = 1; $my_query = new wp_query( 'cat='.$mts_options['mts_trending_articles_cat'].'&posts_per_page=5&ignore_sticky_posts=1' ); ?>
    										<?php if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); ?>
    
    						<li class="trendingPost <?php if($i % 4 == 0){echo 'last';} ?>">
    							<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>" rel="bookmark"><?php mts_short_title('...', 20); ?></a>
    						</li>
    					<?php $i++; endwhile; endif;?>
    
    				</ul>
    
    			</div>
    		<?php }} ?>

    https://wordpress.org/plugins/polylang/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Chouby

    (@chouby)

    Hi!

    You are querying a category defined by $mts_options['mts_trending_articles_cat'], which I suppose is referring to an English category. So you need to get this category translated. As it seems that you can set it from theme options, You can create a wpml-config.xml file to get this option (and possibly others) in strings translations.

    Alternatively, you can create a child theme and translate it directly in the code with pll_get_term

    Thread Starter clcp92

    (@clcp92)

    Sorry I don’t Know how to start with the wpml-config.xml file and I don’t Know how to use pll_get_term Any Example? Or how I can Start

    For now i Start to use this

    <?php
     $currentlang = get_bloginfo('language');
     if($currentlang=="en-US"):
    ?>
     <div>Content in English</div>
    <?php else: ?>
     <div>Content in Spanish (or other language)</div>
    <?php endif; ?>
    Plugin Author Chouby

    (@chouby)

    You don’t need to do all this. As explained in the doc, it’s as easy as replacing $mts_options['mts_trending_articles_cat'] by pll_get_term($mts_options['mts_trending_articles_cat'])

    Thread Starter clcp92

    (@clcp92)

    Sorry, I Try to it, Is this How I have to do it….Im not that good on this

    <?php if(isset(pll_get_term($mts_options['mts_trending_articles_cat'])) { if($mts_options['mts_trending_articles'] == '1' && $mts_options['mts_trending_articles'] != '') { ?>

    That Don’t work so, I’m doing something wrong…

    Plugin Author Chouby

    (@chouby)

    Sorry. I should have been clearer. Not here but on the line:

    <?php $i = 1; $my_query = new wp_query( 'cat='.pll_get_term($mts_options['mts_trending_articles_cat']).'&posts_per_page=5&ignore_sticky_posts=1' ); ?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How can I Make polylang Detect the language in this Code.’ is closed to new replies.