Ответы в темах

Просмотр 1 ответа (всего 1)
  • Нашел в codex вот что

    <?php $my_query = new WP_Query('category_name=featured&posts_per_page=1');
      while ($my_query->have_posts()) : $my_query->the_post();
      $do_not_duplicate = $post->ID;?>
        <!-- Do stuff... -->
      <?php endwhile; ?>
        <!-- Do other stuff... -->
      <?php if (have_posts()) : while (have_posts()) : the_post();
      if( $post->ID == $do_not_duplicate ) continue; ?>
       <!-- Do stuff... -->
      <?php endwhile; endif; ?>

    Написано, что как раз такой реализации, и переменная есть чтобы дублирования не было

    Попробовал перевести на свой вариант:

    <div class="cat-block">
       <h3>Тест</h3>
          <?php
             $the_query = new WP_Query('cat=1&posts_per_page=1');
             while ($the_query->have_posts()) : $the_query->the_post();
             $do_not_duplicate = $post->ID;?>
                <div class="latest">
                   <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(array(250,250), array ('class' => 'alignleft', 'alt' => '', 'title'=>'')); ?></a>
                </div>
             <?php endwhile; ?>
                <?php $the_query = new WP_Query('cat=1&posts_per_page=3');
                while ($the_query->have_posts()) : $the_query->the_post();
                if( $post->ID == $do_not_duplicate ) continue; ?>
                   <div class="few_post">
                      <ul>
                         <li>
                            <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(array(75,75), array ('class' => 'alignleft', 'alt' => '', 'title'=>'')); ?></a>
    					<h4><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h4>
    <div class="sidebar-date"><span class="sidebar-day"><?php the_time('d'); ?></span> <?php the_time('F Y'); ?></div>
    					<div class="clear"></div>
                         </li>
                      </ul>
                   </div>
                <?php endwhile; endif; ?>
          <div class="clear"></div>
    </div>

    ругается на строку <?php endwhile; endif; ?>. пишет Parse error: syntax error, unexpected T_ENDIF in Z:\home\…. Что не так, подскажите?

Просмотр 1 ответа (всего 1)