2013-10-08 22 views
2

我有一個單一的主題我在我的WordPress的使用,但我想改變我的'內容div'手動使用PHP這是目前我正在嘗試做的事:WordPress的如果條件添加樣式到div

<div id="main" class="site-main"> 
    <div class="content" style="<?php if (is_page('Contact Us'){ echo 'width: 870px;'; } ?>"> 
     <div class="lft"> 
      <?php if(have_posts()) : ?> 
       <?php while (have_posts()) : the_post() ?> 

       <div class="horizontal-divider"> 
        <h1><?php the_title(); ?></h1> 
       </div> 
       <?php the_content(); ?> 

       <?php endwhile; ?> 
      <?php endif; ?> 
     </div> 
     <div class="rgt"> 
      <?php 
       get_sidebar(); 
      ?> 
     </div> 

    </div> 
</div> 

<?php get_footer(); ?> 

,你可以看到這行:

<div class="content" style="<?php if (is_page('Contact Us'){ echo 'width: 870px;'; } ?>"> 

就是我試圖使用PHP的div大小更改爲100%,但我不斷收到此錯誤:

Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\wp\aaco\wp-content\themes\aaco-theme\index.php on line 4 

回答

0

你缺少一個)的後面聯繫我們+

固話:

<div class="content" style="<?php if (is_page('Contact Us')){ echo 'width: 870px;'; } ?>"> 
+0

對不起,菜鳥的錯誤。^_ ^ –

0

看起來您的代碼中有拼寫錯誤。您在if語句中缺少)。您希望該行爲:

<div class="content" style="<?php if (is_page('Contact Us')) { echo 'width: 870px;'; } ?>"> 
2

您忘記關閉if的條件。

if (is_page('Contact Us')) 
     ------------------^ 
0
<div class="content" style="<?php if (is_page('Contact Us')){ echo 'width: 870px;'; } ?>"> 
                 ^ 
                  | 

支架失蹤......

感謝。