0
这是显示类别的帖子。但它有一些错误,请修复它。WordPress短代码显示一些错误
这是我的WordPress的简码
function my_form_shortcode($atts) {
ob_start();
$atts = shortcode_atts(
array(
'cat' => '1',
'showposts' => '5',
), $atts, 'my_form_shortcode');
//YOUR CODE START
$recent = new WP_Query();
$query = "cat=".$atts['cat']."&showposts=".$atts['showposts'];
$recent->query($query);
$is_first_post = true;
while($recent->have_posts()) : $recent->the_post(); ?>
<div class="panel-heading"><?php the_category(', '); ?></div>
<ul class="panel-grid">
<li class="ex">
<?php
if ($is_first_post && has_post_thumbnail()) {
the_post_thumbnail('image', array('class' => 'img-responsive'));
$is_first_post = false;
}
?>
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</li>
</ul>
<?php endwhile;
//YOUR CODE END
return ob_get_clean();
}
add_shortcode('my_form_shortcode', 'my_form_shortcode');
在所有岗位在此之前的代码类别标题名称显示。但我只想在第一篇文章之前展示类别标题。这段代码有什么问题。请帮助我..
,但我需要这个代码猫称号。 –