Wordpress query_posts 添加两个“后条目” div,一个带有“后缩略图”的 div和一个没有

发布于 2024-09-19 19:19:09 字数 427 浏览 7 评论 0原文

您好,我的名字是安东尼,这是我的第一个问题。我目前正在制作一个 worpress 主题。在循环中,我想要两个“后输入”div,一个很小,靠近我的帖子拇指,另一个没有拇指。

我知道我需要做一个

<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 } ?>

任何帮助将不胜感激,因为我已经坚持了几天了。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

檐上三寸雪 2024-09-26 19:19:09

作为参考,以下是可放置在循环中的可用模板标签:

http://codex.wordpress.org/Template_Tags< /a>

听起来您需要使用 the_excerpt

(): http://codex.wordpress.org /Function_Reference/the_excerpt

和 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; ?>

For reference here are the available Template Tags to place in your LOOP:

http://codex.wordpress.org/Template_Tags

It sounds like you need to use the

the_excerpt(): http://codex.wordpress.org/Function_Reference/the_excerpt

And the_content(): http://codex.wordpress.org/Function_Reference/the_content

Perhaps you need to look over the loop:

<!-- 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; ?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文