WordPress的query_posts添加了两个"post-entry". div,带有“后缩略图"的div还有一个没有 [英] Wordpress query_posts adding two "post-entry" divs, one with "post-thumbnail" and one without
问题描述
您好,我叫安东尼,这是我的第一个问题.我目前正在制作一个糟糕的主题.并且在循环中,我希望有两个后输入" div,其中一个较小,位于我的后拇指旁边,另一个用于不具有拇指.
Hi my name is Antony and this is my first question. I'm currently making a worpress theme. And in the loop I want to have two "post-entry" divs one that's small that goes next to my post thumb, and one for without the thumb.
我知道我需要做一个
I know that I need to do a
<div class="post">
<?php if ( has_post_thumbnail()) { ?><div class="post-thumb"> <?php the_post_thumbnail(); ?> </div> <div class="post-entry-1"> <? } else { ?><div class="post-entry-2"> <?php } ?>
任何帮助将不胜感激,因为我已经坚持了几天.
Any help will be greatly appreciated, as I have been stuck on this for a few days now.
推荐答案
作为参考,以下是可放置在您的LOOP中的可用模板标签:
For reference here are the available Template Tags to place in your LOOP:
http://codex.wordpress.org/Template_Tags
听起来您需要使用
the_excerpt(): http://codex.wordpress.org/Function_Reference/the_excerpt
the_excerpt(): http://codex.wordpress.org/Function_Reference/the_excerpt
和the_content(): http://codex.wordpress.org/Function_Reference/the_content
And the_content(): http://codex.wordpress.org/Function_Reference/the_content
也许您需要查看循环:
<!-- Start the Loop. -->
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<!-- The following tests if the current post is in category 3. -->
<!-- If it is, the div box is given the CSS class "post-cat-three". -->
<!-- Otherwise, the div box will be given the CSS class "post". -->
<?php if ( in_category('3') ) { ?>
<div class="post-cat-three">
<?php } else { ?>
<div class="post">
<?php } ?>
<!-- Display the Title as a link to the Post's permalink. -->
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. -->
<small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>
<!-- Display the Post's Content in a div box. -->
<div class="entry">
<?php the_content(); ?>
</div>
<!-- Display a comma separated list of the Post's Categories. -->
<p class="postmetadata">Posted in <?php the_category(', '); ?></p>
</div> <!-- closes the first div box -->
<!-- Stop The Loop (but note the "else:" - see next line). -->
<?php endwhile; else: ?>
<!-- The very first "if" tested to see if there were any Posts to -->
<!-- display. This "else" part tells what do if there weren't any. -->
<p>Sorry, no posts matched your criteria.</p>
<!-- REALLY stop The Loop. -->
<?php endif; ?>
这篇关于WordPress的query_posts添加了两个"post-entry". div,带有“后缩略图"的div还有一个没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!