View Full Version : سوال: مشکل loop از چیه؟
  
ABZiko
چهارشنبه 10 دی 1393, 23:06 عصر
سلام، این قسمت پست های بنده برای نمایش در وردپرس است، ولی یک مشکلی هست وقتی این کد رو دورش قرار می دم چیزی نمایش نمی ده :
                    <?php if ( have_posts() ) : ?>
                    <?php while ( have_posts() ) : the_post(); ?>         
                    <?php endwhile; ?>
                    <?php endif; ?>        
ولی وقتی برش می دارم آخرین پست رو نمایش می ده (که درست هم است) ، ولی مشکل loop از چیه؟
mr.mostafa.shiraali
پنج شنبه 11 دی 1393, 04:24 صبح
این را امتحان کنید
 <?php if (have_posts()) : while (have_posts()) : the_post();?>
ABZiko
پنج شنبه 11 دی 1393, 13:11 عصر
نه متاسفانه بازم کار نکرد !
mr.mostafa.shiraali
پنج شنبه 11 دی 1393, 13:53 عصر
شما HTML هر پست را می نویسید؟ کد کامل بشکل زیر مثلاً باید باشد
  <?php if (have_posts()) : while (have_posts()) : the_post();?>
  <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <div class = "title">
      <h2><a href = "<?php the_permalink()?>" title ="<?php the_title()?>">
        <?php the_title()?>
        </a></h2>
    </div>
    <div class = "date">
      <?php the_time('j F , Y');?>
    </div>
    <div class = "post-top"></div>
    <div class = "post-body">
      <div class = "margin">
        <div class = "meta-post">
          <div class = "cat-post">
            <?php the_category('/ ') ?>
          </div>
        </div>
        <div class = "clear"></div>
        <div class="postThumb">
          <?php post_image_thumbnail(); ?>
        </div>
        <div class = "excerpt">
          <?php wpe_excerpt('wpe_excerptlength_index', ''); ?>
        </div>
      </div>
    </div>
    <div class = "post-bottom"></div>
  </div>
  <a href="<?php the_permalink(); ?>" class="readmore">
  <?php _e('Read More','pctriks'); ?>
  </a>
  <div class = "author-post">
    <?php  the_author(); ?>
  </div>
  <div class = "comment-post">
   <!--Your Code Here -->
  </div>
  <?php endwhile;?>
 
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.