应用帖子标题过滤器:上次查看的帖子+qTranslate

时间:2012-09-09 作者:Phantasmix

我正在一个支持qTranslate的网站上使用上次查看的帖子(LVP)插件。LVP以两种语言显示帖子标题。我发现了以下提示:titles in recent posts appear together in all languages with qtranslate

但不确定如何应用此筛选器。LVP中的相关代码:

        foreach ($zg_post_IDs as $value) { // Do output as long there are posts
        global $wpdb;
        $zg_get_title = $wpdb->get_results("SELECT post_title FROM $wpdb->posts WHERE ID = \'$value+0\' LIMIT 1");
        foreach($zg_get_title as $zg_title_out) {
            echo "<a href=\\"". get_permalink($value+0) . "\\" title=\\"". $zg_title_out->post_title . "\\">". $zg_title_out->post_title . "</a>, \\n"; // Output link and title
        }
而不是echo $post->post_title; 它有$zg_title_out->post_title.

将整个zg管柱替换为apply_filters(\'the_title\',$post->post_title) 不起作用。

1 个回复
最合适的回答,由SO网友:Phantasmix 整理而成

解决方案-

取出:
foreach($zg_get_title as $zg_title_out) { echo "<a href=\\"". get_permalink($value+0) . "\\" title=\\"". $zg_title_out->post_title . "\\">". $zg_title_out->post_title . "</a>, \\n"; // Output link and title

插入:

foreach($zg_get_title as $post) { echo "<a href=\\"". get_permalink($value+0) . "\\" title=\\"". $post->post_title . "\\">". apply_filters(\'the_title\',$post->post_title) . "</a>; \\n"; // Output link and title

$zg_title_out 已替换为$post,
$zg_title_out->post_title 已替换为$post->post_title

结束

相关推荐