2017-02-15 38 views
0

我一直在試圖把博客標題放在我的自定義夸克主題的博客文章下面。然而,每次我這樣做,我得到一個空白博客文章頁面(除了頭)試圖把下面的博客標題放在夸克上的精選圖片

的代碼是:

<header class="entry-header"> 
      <?php if (is_single()) { ?> 
       <h1 class="entry-title"><?php the_title(); ?></h1> 
      <?php } 
      else { ?> 
       <h1 class="entry-title"> 
        <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr(sprintf(esc_html__('Permalink to ', 'quark') . '%s', the_title_attribute('echo=0'))); ?>" rel="bookmark"><?php the_title(); ?></a> 
       </h1> 
      <?php } // is_single() ?> 
      <?php quark_posted_on(); ?> 
      <?php if (has_post_thumbnail() && !is_search()) { ?> 
       <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr(sprintf(esc_html__('Permalink to ', 'quark') . '%s', the_title_attribute('echo=0'))); ?>"> 
        <?php the_post_thumbnail('post_feature_full_width'); ?> 
       </a> 
      <?php } ?> 

我將其更改爲:

<header class="entry-header"> 
        <?php } // is_single() ?> 
      <?php quark_posted_on(); ?> 
      <?php if (has_post_thumbnail() && !is_search()) { ?> 
       <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr(sprintf(esc_html__('Permalink to ', 'quark') . '%s', the_title_attribute('echo=0'))); ?>"> 
        <?php the_post_thumbnail('post_feature_full_width'); ?> 
       </a> 

    <?php if (is_single()) { ?> 
       <h1 class="entry-title"><?php the_title(); ?></h1> 
      <?php } 
      else { ?> 
       <h1 class="entry-title"> 
        <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr(sprintf(esc_html__('Permalink to ', 'quark') . '%s', the_title_attribute('echo=0'))); ?>" rel="bookmark"><?php the_title(); ?></a> 
       </h1> 

      <?php } ?> 

我也嘗試過多種變體這很少成功。我確信我很愚蠢,但任何幫助都會很棒。

謝謝!

回答

1

嘗試以下方法(根據我的第一答案和註釋以上):

<header class="entry-header"> 
     <?php quark_posted_on(); ?> 
     <?php if (has_post_thumbnail() && !is_search()) { ?> 
      <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr(sprintf(esc_html__('Permalink to ', 'quark') . '%s', the_title_attribute('echo=0'))); ?>"> 
       <?php the_post_thumbnail('post_feature_full_width'); ?> 
      </a> 
     <?php } ?> 
<?php if (is_single()) { ?> 
      <h1 class="entry-title"><?php the_title(); ?></h1> 
     <?php } 
     else { ?> 
      <h1 class="entry-title"> 
       <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr(sprintf(esc_html__('Permalink to ', 'quark') . '%s', the_title_attribute('echo=0'))); ?>" rel="bookmark"><?php the_title(); ?></a> 
      </h1> 

     <?php } ?> 
+0

這工作完美,謝謝你的人!大量地讓我感到沮喪。 – Max

+1

太棒了,很高興得到了幫助!正如我在下面的其他答案中所提到的,問題是由於在某些地方沒有相應的標籤(即關閉或打開標籤丟失)。快速識別這種情況的一種潛在方法是取出所有非PHP代碼,並查看代碼中是否都可以。 – asugrue15

+1

今後調試時我會記住這一點,歡呼! – Max

0

第二行可能會導致問題,除非有相應的{上面的某處?

+0

同樣,有沒有收}某處的{在你的代碼的第四行? – asugrue15