首页轮播排序问题(补充标题字数)

  • Kk78807844

  • 2017年10月19日

现在首页标题是按照文章ID数值排序,后台设定无效

undefined

我的后台设定,我的前台(www.c3acg.com) 希望调整下

  • 473次浏览
  • 0收藏
  • 0喜欢
    • Touchumind

    • 2017年10月19日
    • 沙发

    @k78807844 

    undefined

    按图示修改对应文件,红色是删除的,绿色是新增的

      • Touchumind

      • 2017年10月19日
      • 板凳
      /**
      * Class SlideVM
      */
      class SlideVM extends BaseVM {
         protected function __construct() {
             $this->_cacheUpdateFrequency = 'daily';
             $this->_cacheInterval = 3600*24;
         }
      
         protected function getRealData() {
             $slide_postIds = explode(',', tt_get_option('tt_home_slides'));
      
             if(!count($slide_postIds)) {
                 return null;
             }
      
             $args = array(
                 'post_type' => 'post',
                 'post_status' => 'publish',
                 'posts_per_page' => -1,
                 'post__in' => $slide_postIds,
                 'has_password' => false,
                 'ignore_sticky_posts' => true,
                 'orderby' => 'none'
             );
      
             $query = new WP_Query($args);
      
             $slide_posts = array();
      
             while ($query->have_posts()) : $query->the_post();
                 $slide_post = array();
                 global $post;
                 $slide_post['title'] = get_the_title($post);
                 $slide_post['permalink'] = get_permalink($post);
                 $slide_post['comment_count'] = $post->comment_count;
                 $slide_post['category'] = get_the_category_list(' · ', '', $post->ID);
                 $slide_post['author'] = get_the_author(); //TODO add link
                 $slide_post['author_url'] = home_url('/@' . $slide_post['author']);
                 $slide_post['time'] = get_post_time('F j, Y', false, $post, false); //get_post_time( string $d = 'U', bool $gmt = false, int|WP_Post $post = null, bool $translate = false )
                 $slide_post['datetime'] = get_the_time(DATE_W3C, $post);
                 $slide_post['thumb'] = tt_get_thumb($post, array(
                     'width' => 750,
                     'height' => 375,
                     'str' => 'large'
                 ));
      
                 $slide_posts[] = $slide_post;
             endwhile;
      
             wp_reset_postdata();
      
             return $slide_posts;
         }
      }
        • Touchumind

        • 2017年10月19日
        • 地板

        @k78807844 

        上面发的代码是没修改过的,这个是修改之后的

        /**
         * Class SlideVM
         */
        class SlideVM extends BaseVM {
            protected function __construct() {
                $this->_cacheUpdateFrequency = 'daily';
                $this->_cacheInterval = 3600*24;
            }
        
            protected function getRealData() {
                $slide_postIds = explode(',', tt_get_option('tt_home_slides'));
        
                if(!count($slide_postIds)) {
                    return null;
                }
        
                $args = array(
                    'post_type' => 'post',
                    'post_status' => 'publish',
                    'posts_per_page' => -1,
                    'post__in' => $slide_postIds,
                    'has_password' => false,
                    'ignore_sticky_posts' => true,
                    'orderby' => 'none'
                );
        
                $query = new WP_Query($args);
        
                $slide_posts = array();
        
                while ($query->have_posts()) : $query->the_post();
                    $slide_post = array();
                    global $post;
                    $slide_post['title'] = get_the_title($post);
                    $slide_post['permalink'] = get_permalink($post);
                    $slide_post['comment_count'] = $post->comment_count;
                    $slide_post['category'] = get_the_category_list(' · ', '', $post->ID);
                    $slide_post['author'] = get_the_author(); //TODO add link
                    $slide_post['author_url'] = home_url('/@' . $slide_post['author']);
                    $slide_post['time'] = get_post_time('F j, Y', false, $post, false); //get_post_time( string $d = 'U', bool $gmt = false, int|WP_Post $post = null, bool $translate = false )
                    $slide_post['datetime'] = get_the_time(DATE_W3C, $post);
                    $slide_post['thumb'] = tt_get_thumb($post, array(
                        'width' => 750,
                        'height' => 375,
                        'str' => 'large'
                    ));
        
                    $slide_posts[strval($post->ID)] = $slide_post;
                endwhile;
        
                wp_reset_postdata();
        
                $ordered_posts = array();
        
                foreach ($slide_postIds as $value) {
                    $ordered_posts[] = $slide_posts[$value];
                }
        
                return $ordered_posts;
            }
        }
          • Kk78807844

          • 2017年10月27日
          • 楼主

          谢大佬

          登录以发表评论