Php 从左侧边栏的热门帖子在单个页面中显示不需要的帖子

Php 从左侧边栏的热门帖子在单个页面中显示不需要的帖子,php,html,css,wordpress,Php,Html,Css,Wordpress,当我使用左侧边栏进行布局时,我的单个页面无法正常工作。这意味着,从左侧边栏的单页查询文章是流行小部件的最后一篇文章 您可以查看下面的屏幕截图 我的班级: class banyansopno_show_popular extends WP_Widget { function banyansopno_show_popular() { $widget_ops = array('classname' => 'banyansopno_show_popular', 'de

当我使用左侧边栏进行布局时,我的单个页面无法正常工作。这意味着,从左侧边栏的单页查询文章是流行小部件的最后一篇文章

您可以查看下面的屏幕截图

我的班级:

class banyansopno_show_popular extends WP_Widget {

    function banyansopno_show_popular() {
         $widget_ops = array('classname' => 'banyansopno_show_popular', 'description' => esc_html__('Show your popular posts.', 'banyansopno'));
         parent::__construct('banyansopno_show_popular', esc_html__('- @ Banyan Popular Posts @ -', 'banyansopno'), $widget_ops);
     }

    function widget($args, $instance){
        extract($args);


         $title = $instance['title'];
         $postscount = $instance['posts'];

        //GET the posts
        $popularpost = new WP_Query( array( 'posts_per_page' => $postscount,'meta_key' => 'wpb_post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC','post__not_in' => get_option( 'sticky_posts' ) ) );

        echo '<h3 class="widget-title">'.$title.'</h3>' ;

        //SHOW the posts

            while ( $popularpost->have_posts() ) : $popularpost->the_post();

            ?>              
            <div class="widget widget_latest_posts_entries">                  
                <ul>
                    <li>
                      <div class="featured-image">
                        <a href="<?php echo esc_url(get_permalink()); ?>"><?php echo get_the_post_thumbnail(); ?></a>         
                      </div>
                      <div class="post-content">
                        <p class="post-title"><a href="<?php echo esc_url(get_permalink()); ?>"><?php the_title(); ?></a></p>
                        <span class="category">
                            <?php if( esc_attr(get_theme_mod( 'show_categories', 1 ) ) ) {
                                banyansopno_categories_list();
                            } ?>
                        </span>
                        <span class="post-date"><?php the_date('F j, Y'); ?> at <?php the_time('g:i a'); ?></span>
                      </div>
                    </li>                    
               </ul>
            </div>
            <?php

            endwhile;

     }

        function update($newInstance, $oldInstance){
             $instance = $oldInstance;
             $instance['title'] = strip_tags($newInstance['title']);
             $instance['posts'] = $newInstance['posts'];

             return $instance;
         }

        function form($instance){

            $title = isset($instance['title'])? $instance['title'] : 'Popular Post\'s';
            echo '<p style="text-align:right;"><label  for="'.$this->get_field_id('title').'">' . esc_html__('Title:', 'banyansopno') . '  <input style="width: 200px;" id="'.$this->get_field_id('title').'"  name="'.$this->get_field_name('title').'" type="text"  value="'.esc_attr($title).'" /></label></p>';

            $posts = isset($instance['posts'])? $instance['posts'] : '3';
            echo '<p style="text-align:right;"><label  for="'.$this->get_field_id('posts').'">' . esc_html__('Number of Posts:', 'banyansopno') . ' <input style="width: 50px;"  id="'.$this->get_field_id('posts').'"  name="'.$this->get_field_name('posts').'" type="text"  value="'.esc_attr($posts).'" /></label></p>';

            echo '<input type="hidden" id="custom_recent" name="custom_recent" value="1" />';
         }
    }    
add_action('widgets_init', create_function('', 'return register_widget("banyansopno_show_popular");'));
class banyansopno\u show\u流行扩展WP\u小部件{
函数banyansopno_show_popular(){
$widget\u ops=array('classname'=>'banyansopno\u show\u popular','description'=>esc\u html\uuuu('show your popular posts','banyansopno');
父项::u构造('banyansopno_show_popular',esc_html_u('-@Banyan popular Posts@-','banyansopno'),$widget_ops);
}
函数小部件($args$instance){
摘录($args);
$title=$instance['title'];
$PostScont=$instance['posts'];
//获得职位
$popularpost=new WP_Query(数组('posts_per_page'=>$postsunt,'meta_key'=>'wpb_post_views_count','orderby'=>'meta_value_num','order'=>'DESC','post_not in'=>get_选项('sticky_posts'));
回显“.$title.”;
//显示帖子
而($popularpost->have_posts()):$popularpost->the_post();
?>              

什么内容没有显示在右边?不清楚…当我点击一个帖子链接时,它不会显示在一个页面中,而是从左侧边栏显示流行小部件的最后一篇文章。请查看屏幕截图并点击另一个帖子链接。请点击另一个帖子链接,你可能会在单个页面中看到相同的帖子,而这篇文章来自左侧边栏的流行帖子t、 什么内容没有显示在右边?不清楚…当我点击一个帖子链接时,它不会显示在一个页面中,而是从左侧边栏显示流行小部件的最后一篇文章。请查看屏幕截图并点击另一个帖子链接。请点击另一个帖子链接,你可能会在单个页面中看到相同的帖子,而这篇文章来自左侧边栏的流行帖子wid得到。