通过短代码显示自定义帖子

时间:2014-08-19 05:34:01

标签: wordpress

我需要下面的matabox img:

function owl_carousel_shortcode( $atts, $content = null  ) {



extract( shortcode_atts( array(

), $atts ) );

$q = new WP_Query(
    array('posts_per_page' => -1, 'post_type' => 'owl_carousel')      
     ); 

$list = '<div id="owl-demo" class="owl-carousel">';
while($q->have_posts()) : $q->the_post();
    $idd = get_the_ID();

    $list .= '

        <div class="item">
            <img class="img-responsive img-thumbnail" src="(I need Img hear by matabox)" alt="img-1">
        </div>

    ';        
endwhile;
$list.= '</div> 
       <div class="customNavigation">
        <a class="prev owl-demo-left"><i class="fa fa-angle-left"></i></a>
        <a class="next"><i class="fa fa-angle-right"></i></a>
    </div>';
wp_reset_query();
return $list;

}   

add_shortcode('owl_carousel', 'owl_carousel_shortcode');

1 个答案:

答案 0 :(得分:0)

替换

<img class="img-responsive img-thumbnail" src="(I need Img hear by matabox)" alt="img-1">        

<img class="img-responsive img-thumbnail" src="'.get_post_meta( $idd, 'your-img-key', true ).'" alt="img-1">
相关问题