ste_yeu on "Polylang doesn't show all the strings from wpml-config.xml"

ساخت وبلاگ

I lost a lot of time for this problem, there were two alteatives to resolve it:

1. Using the shortcodes [polylang]:

// [polylang lang="en"]English[/polylang][polylang lang="sp"]Spanish[/polylang]
function polylang_shortcode($atts, $content = null)
{ if (empty($content)) retu ''; extract( shortcode_atts( array('lang' => ''), $atts ) ); if (empty($lang)) retu "<h3>You must specify 'lang' using shortcode: polylang</h3>"; retu ($lang == pll_current_language()) ? $content : '';
}
add_shortcode('polylang', 'polylang_shortcode');

Refer: https://wordpress.org/support/topic/polylang-shortcode-like-qtranslate-for-theme-options-and-text?replies=19

This trick saved me many times, I think that the developers should integrate it.

Unfortunately in many fields of this theme I can't use shortcodes, so I could not use this trick.

2. Using php code, and I resolved in this way, so I had to edit the php file of theme section:

<?php $url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; // get current url if (false !== strpos($url,'/en/')) { // if in url I find the string /en/ echo 'eng'; } elseif (false !== strpos($url,'/it/')) { // if in url I find the string /it/ echo 'ita'; } ?>

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 358 تاريخ : جمعه 31 ارديبهشت 1395 ساعت: 17:38

خبرنامه