PHP通过短代码始终位于页面顶部

PHP通过短代码始终位于页面顶部,php,wordpress,shortcode,Php,Wordpress,Shortcode,我有一个wordpress插件来显示最受欢迎的帖子 但是当我通过快捷码添加它时,它总是到达页面顶部,而不是我放置它的位置。。。我改变了插件PHPs中的每个回音以返回,但没有帮助。。。下面是我在functions.php中的短代码: function top_news(){ $args=数组( “限制”=>15, “范围”=>“每日”, “新鲜度”=>1, “订单依据”=>“视图”, “post_type”=>“post”, “统计视图”=>1, 'stats_author'=>1, “统计数据

我有一个wordpress插件来显示最受欢迎的帖子

但是当我通过快捷码添加它时,它总是到达页面顶部,而不是我放置它的位置。。。我改变了插件PHPs中的每个回音以返回,但没有帮助。。。下面是我在functions.php中的短代码:

function top_news(){
$args=数组(
“限制”=>15,
“范围”=>“每日”,
“新鲜度”=>1,
“订单依据”=>“视图”,
“post_type”=>“post”,
“统计视图”=>1,
'stats_author'=>1,
“统计数据日期”=>1,
“wpp_start”=>“DatumTop Nachricten von HeuteLeser”,
“wpp_end'=>”,
'stats\u date\u format'=>'d',
“文字摘录”=>1,
“摘录长度”=>35,
“标题长度”=>66,
'post_html'=>'{date}.Aug
+{summary}
{views}' ); wpp最受欢迎($args); 返回$args; } 添加_短代码('topnews','top_news')在阅读的文档时,它声明该函数实际打印流行帖子。这意味着你的热门帖子在返回任何内容之前就被打印出来了,而且因为所有的短码都是在帖子内容被打印之前被处理的,这就是为什么你的热门帖子总是打印在帖子内容之前(顶部)

因此,您可以在缓冲区中捕获所有流行的帖子

function top_news(){
     $args = array (
        'limit' => 15,
        'range' => 'daily',
        'freshness' => 1,
        'order_by' => 'views',
        'post_type' => 'post',
        'stats_views' => 1,
        'stats_author' => 1,
        'stats_date' => 1,
        'wpp_start' => '<table class="topnachrichten"><tr><th>Datum</th><th>Top Nachrichten von Heute</th><th>Leser</th></tr>',
        'wpp_end' => '</table>',
        'stats_date_format' => 'd',
        'excerpt_by_words' => 1,
        'excerpt_length' => 35,
        'title_length' => 66,
        'post_html' => '<tr><td class="datum">{date}. Aug</td><td class="stext"><details>
        <summary><a href="{url}">{title}</a><span class="plus">+</span></summary>{summary}<br><a href="{url}">Weiterlesen</a></details></td><td class="views">{views}</td></tr>'
    );

    ob_start();
    wpp_get_mostpopular( $args );
    $output = ob_get_contents();
    ob_end_clean();

    return $output;
}
add_shortcode( 'topnews', 'top_news' );
function top_news(){
$args=数组(
“限制”=>15,
“范围”=>“每日”,
“新鲜度”=>1,
“订单依据”=>“视图”,
“post_type”=>“post”,
“统计视图”=>1,
'stats_author'=>1,
“统计数据日期”=>1,
“wpp_start”=>“DatumTop Nachricten von HeuteLeser”,
“wpp_end'=>”,
'stats\u date\u format'=>'d',
“文字摘录”=>1,
“摘录长度”=>35,
“标题长度”=>66,
'post_html'=>'{date}.Aug
+{summary}
{views}' ); ob_start(); wpp最受欢迎($args); $output=ob_get_contents(); ob_end_clean(); 返回$output; } 添加_短代码('topnews','top_news');