WordPress query_posts добавление двух div-элементов "post-entry", одного с "post-thumbnail" и одного без - PullRequest
1 голос
/ 18 сентября 2010

Привет, меня зовут Антоний, и это мой первый вопрос. В настоящее время я делаю тему Wpress. И в цикле я хочу иметь два div-элемента "post-entry", один маленький, который идет рядом с большим пальцем моего поста, и один без большого пальца.

Я знаю, что мне нужно сделать

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

Буду очень признателен за любую помощь, так как я застрял на этом в течение нескольких дней.

1 Ответ

0 голосов
/ 20 сентября 2010

Для справки вот доступные теги шаблонов для размещения в вашем LOOP:

http://codex.wordpress.org/Template_Tags

Звучит так, как будто вам нужно использовать

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; ?>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...