这些代码在我的Shortcodes PHP文件中:
function zboom_slider($atts,$content){
ob_start();
$blockattr = extract(shortcode_atts(array(
'number' => '2'
),'$atts'));
?>
<div class="row-fliud clearfix" id="our-team">
<h1>Our Team</h1>
<?php $team=new WP_Query(array(
'post_type' => 'team-member',
'posts_per_page' => $number
));
while($team->have_posts()): $team->the_post(); ?>
<div class="span3" id="member1">
<a href="#"><?php the_post_thumbnail(); ?></a>
<h4><?php the_title(); ?></h4>
<span><?php $teamskills=get_the_terms(get_the_id(),'team-skill');
foreach($teamskills as $teamcat){
echo $teamcat->name;
}
?></span>
<p><?php the_content(); ?></p>
</div>
<?php endwhile; ?>
</div>
<?php $myslider= ob_get_clean();
return $myslider;
}
add_shortcode('shortslider','zboom_slider');
'number'属性被用作'posts_per_page'值中的变量,该值将定义在页面中显示多少个帖子。
这是我用作具有属性的简码:
[shortslider number =“ 3”]