【问题标题】:how to translate preg_match_all results with qtranslate plugin in wordpress?如何在 wordpress 中使用 qtranslate 插件翻译 preg_match_all 结果?
【发布时间】:2011-12-27 06:38:25
【问题描述】:

我真的需要一些帮助。

我有一个功能可以提取[internet]blablabla[/internet]preg_match_all 完成的短代码之间的内容

function get_content($my_post) {
      $post_id = $my_post; //$_GET["p"];
      $queried_post = get_post($post_id);
      $title = $queried_post->post_title;

      preg_match_all('#\[internet\](.+)\[\/internet\]#', $queried_post->post_content, $matches);
      //var_dump($matches[1][0]);

      if ( is_single( ) ) {
      echo '<br><br><h1>'.$matches[1][0].'</h1>';
      echo '<br><br><a href="http://moldcell.info/ts/?p='.$my_post.'&amp;'.$matches[1][0].'">get url</a>';


   }

   }

我的网站支持 3 种语言(英语、罗马尼亚语、俄语)。当我放置qtranslate的条件标签时,它没有翻译,但它给了我默认语言的值。

如何翻译?

提前谢谢你。

P.S.:我已经在 qtranslate 支持论坛上发布了这个,但没有回复。也许 SO 的人可以帮助我。

【问题讨论】:

    标签: preg-match-all shortcode qtranslate


    【解决方案1】:

    这就是答案:

    echo '<br><br><a href="http://moldcell.info/ts/?p='.$my_post.'&amp;'.$matches[1][1].'">get url</a>';
    

    echo '<br><br><a href="http://moldcell.info/ts/?p='.$my_post.'&amp;'.$matches[1][2].'">get url</a>';
    

    【讨论】:

      猜你喜欢
      • 2013-05-10
      • 1970-01-01
      • 2016-11-04
      • 2017-08-07
      • 1970-01-01
      • 2015-10-12
      • 1970-01-01
      • 1970-01-01
      • 2015-02-11
      相关资源
      最近更新 更多