theme development - wordpress custom category post shortcode

Does not work this code...function category_post_shortcode($atts){extract(shortcode_atts(array('title' => &

Does not work this code...

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>';

        while($q->have_posts()) : $q->the_post();
        $id = get_the_ID();
109 no line =>    $post_excerpt = get_post_meta($id, 'post_excerpt', true);
        $post_thumbnail = get_the_post_thumbnail( $post->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' );

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744893144a4599534.html

相关推荐

  • theme development - wordpress custom category post shortcode

    Does not work this code...function category_post_shortcode($atts){extract(shortcode_atts(array('title' => &

    1天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信