2016-02-28 83 views
0

我操縱數據來切換顯示時的位置。數據在if結構上。數據分爲三類,我認爲類別,日期和標題。當前的結構是類別,日期和標題響應。我想將其更改爲日期,標題和類別。但我有一些錯誤。如果語句不工作結束wordpress

PHP代碼:

 <?php if ($displays_date) { ?> 
      <time class="entry-date published" datetime="<?php the_time('c'); ?>"><?php the_time(get_option('date_format')); ?></time> 
      <time class="updated" datetime="<?php the_modified_time('c'); ?>"><?php the_modified_time(get_option('date_format')); ?></time> 
     <?php } ?> 


     <?php if ($displays_cat) { ?> 
      <span class="entry-category"> 
       <?php the_category(', '); ?> 
      </span> 
     <?php } ?> 

     <?php if (! is_category()) { // Do not display category name in category pages ?> 
     <span class="entry-category"> 
      <?php the_category(', '); ?> 
     </span> 
     <?php } ?> 

     <?php 
     // Date 
     global $ti_option; 
     if ($ti_option['post_item_date'] == '1') : 
     ?> 
      <time class="entry-date published" datetime="<?php the_time('c'); ?>"><?php the_time(get_option('date_format')); ?></time> 
      <time class="updated" datetime="<?php the_modified_time('c'); ?>"><?php the_modified_time(get_option('date_format')); ?></time> 
     <?php endif; ?> 


     <?php content_post_item_title(); ?> 

試圖做這樣這樣。它有關於endif的一些錯誤。

 <?php if ($displays_date) { ?> 
      <time class="entry-date published" datetime="<?php the_time('c'); ?>"><?php the_time(get_option('date_format')); ?></time> 
      <time class="updated" datetime="<?php the_modified_time('c'); ?>"><?php the_modified_time(get_option('date_format')); ?></time> 
     <?php } ?> 

     <?php 
     // Date 
     global $ti_option; 
     if ($ti_option['post_item_date'] == '1') : 
     ?> 
      <time class="entry-date published" datetime="<?php the_time('c'); ?>"><?php the_time(get_option('date_format')); ?></time> 
      <time class="updated" datetime="<?php the_modified_time('c'); ?>"><?php the_modified_time(get_option('date_format')); ?></time> 
     <?php endif; ?> 


     <?php content_post_item_title(); ?> 


     <?php if ($displays_cat) { ?> 
      <span class="entry-category"> 
       <?php the_category(', '); ?> 
      </span> 
     <?php } ?> 

     <?php if (! is_category()) { // Do not display category name in category pages ?> 
     <span class="entry-category"> 
      <?php the_category(', '); ?> 
     </span> 
     <?php endif; ?> 

我在我的WordPress網站上運行這個。

回答

0

在代碼的最後一塊,你正在使用「ENDIF」

嘗試更換「ENDIF」的閉架:

<?php if (! is_category()) { // Do not display category name in category pages ?> 
    <span class="entry-category"> 
     <?php the_category(', '); ?> 
    </span> 
<?php } ?> 
0

發現該if語句沒有連接在一起,可以是移動而不更改任何代碼。

 <?php if ($displays_date) { ?> 
      <time class="entry-date published" datetime="<?php the_time('c'); ?>"><?php the_time(get_option('date_format')); ?></time> 
      <time class="updated" datetime="<?php the_modified_time('c'); ?>"><?php the_modified_time(get_option('date_format')); ?></time> 
     <?php } ?> 

     <?php 
     // Date 
     global $ti_option; 
     if ($ti_option['post_item_date'] == '1') : 
     ?> 
      <time class="entry-date published" datetime="<?php the_time('c'); ?>"><?php the_time(get_option('date_format')); ?></time> 
      <time class="updated" datetime="<?php the_modified_time('c'); ?>"><?php the_modified_time(get_option('date_format')); ?></time> 
     <?php endif; ?> 


     <?php content_post_item_title(); ?> 

     <?php if ($displays_cat) { ?> 
      <span class="entry-category"> 
       <?php the_category(', '); ?> 
      </span> 
     <?php } ?> 

     <?php if (! is_category()) { // Do not display category name in category pages ?> 
     <span class="entry-category"> 
      <?php the_category(', '); ?> 
     </span> 
     <?php } ?>