最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

categories - Post does not show category wish just show latest post

programmeradmin2浏览0评论
function category_post_shortcode($atts){
                extract(shortcode_atts(array(
                  'title' => '',
                  'link'  => '',
                  'category' => '',
                ), $atts, 'category_post' ) );

                $q = new WP_Query(
                  array( 'category' => $category, 'posts_per_page' => '3', 'post_type' => 'post')
                );

                $list = '<div class="latest_form_category"><h2 class="latest_form_category_title">'.$title.'</h2><a href="'.$link.'" class="latest_more_link">More</a><div class="total_cat_post">';

                while($q->have_posts()) : $q->the_post();
                $id = get_the_ID();

                $post_excerpt = get_post_meta($id, 'post_excerpt', true);
                $post_thumbnail = get_the_post_thumbnail( $id, 'post-thumbnail');
                $list .= '
                          <div class="single_cat_post floatleft">
                            '.$post_thumbnail.'
                            <h3>'.get_the_title().'</h3>
                            <p>'.$post_excerpt.'</p>
                            <a href="'.get_permalink().'" class="readmore">Read More</a>
                          </div>

                  ';
                endwhile;
                $list .= '</div>';
                wp_reset_query();
                return $list;
                  }
                  add_shortcode( 'category_post', 'category_post_shortcode' );
发布评论

评论列表(0)

  1. 暂无评论