使用WPML在PHP中进行翻译

时间:2013-07-12 18:43:44

标签: php wordpress translation wpml

我目前正在使用WPML浏览基于Wordpress的网站上的静态模板文件,并想知道如何设置这个PHP代码可以翻译:

<?php echo preg_replace("/href=\"([^\"]*)\"/", "href=\"$1#activity-filter\"", get_next_posts_link('Next Activities &raquo;')); ?>

特别是“下一个活动”文字。

目前我正在包装其他HTML行:

<p><?php _e('Words that are being translated', 'roots'); ?></p>

感谢。

2 个答案:

答案 0 :(得分:0)

它会像:

$translate = __( 'Next Activities &raquo;', 'roots' );
echo preg_replace(
    "/href=\"([^\"]*)\"/", 
    "href=\"$1#activity-filter\"", 
    get_next_posts_link( $translate )
);

当代码过于复杂时使用此方法。

相关:

答案 1 :(得分:-2)

Wordpress默认情况下不允许您在页面中包含php,但是有Exec-PHP之类的插件可以让你这样做。