2014-03-26 21 views
0

嘿,我的wordpress中的php代碼有問題。如果有圖像,我想要有不同的部分課程。所以如果存在非圖像,我可以使文本居中,如果存在,則使其浮動到右側。如果特色圖片存在或不存在,則顯示不同的post-typ

<?php if (have_posts()) : while (have_posts()) : the_post(); ?> 

<?php if(has_post_thumbnail()); ?> 
    <section class="post"> 
     <?php the_post_thumbnail('full'); ?> 
     <div class="posts-data"> 
      <h2><?php the_title(); ?></h2> 
      <p><?php the_excerpt(); ?></p> 
     </div> 
    </section> 
<?php else: ?> 
    <section class="post-no-img"> 
     <h2><?php the_title(); ?></h2> 
     <p><?php the_excerpt(); ?></p> 
    </section> 
<?php endif; ?> 

<?php endwhile; else: ?> 

<p>There are no post or pages</p> 

<?php endif; ?> 

我得到這個worning:

Parse error: syntax error, unexpected 'else' (T_ELSE) in C:\xampp\htdocs\Fortagsida\wp-content\themes\foretagblog\front-page.php on line 12

線12。

回答

1

在第3行,它應該是<?php if(has_post_thumbnail()): ?>(:不是;)

+0

Thnaks:d,這是如此容易:P – user2333038

0

你可能想要把 「:」 第二如果

相關問題