【发布时间】:2019-09-18 20:30:48
【问题描述】:
我想在类别页面中使用 wp_query 循环并使用下面的代码,但它得到一个错误:“该站点遇到技术问题。” .那么如何改进我的代码呢?感谢您的帮助! [![在此处输入图片描述][1]][1]
<?php if(have_posts()) : while(have_posts()) : the_post();
?>
<?php
if($counter == 1) :
?>
<div class="col-<?php echo counter; ?>"> //this col have width 50%, height 300px.
<div class="postimage">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('project-thumb'); ?></a>
</div>
<div class="proj-title"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>
</div>
<?php
elseif($counter == 2) :
?>
<div class="col-<?php echo counter; ?>"> //this col have width 50%, height 150px.
<div class="postimage">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('project-thumb'); ?></a>
</div>
<div class="proj-title"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>
</div>
<div class="clear"></div>
<?php
elseif($counter == 3) :
?>
<div class="col-<?php echo counter; ?>"> //this col have width 50%, height 150px.
<div class="postimage">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('project-thumb'); ?></a>
</div>
<div class="proj-title"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>
</div>
<?php endif; ?>
[1]: https://i.stack.imgur.com/jgolS.png
【问题讨论】:
-
你遇到了什么错误,你想要的结果是什么?
-
这是 html css 模板:codepen.io/tu1988/pen/YzKJbKb ,我想回显 number 来计算 class col-{number} 。我把这段代码放到我的类别模板中,并希望所有的帖子循环都是 mansory
标签: wordpress gridview masonry