2

我在我的 wordpress 中使用了一个主题,但我想使用 php 手动更改我的“内容 div”的 css,这是我目前正在尝试做的:

<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
4

4 回答 4

2

你忘了关闭if条件。

if (is_page('Contact Us'))
       ------------------^
于 2013-10-08T12:11:46.653 回答
0

看起来您的代码中有错字。您)的 if 语句中缺少 a 。您希望该行是:

<div class="content" style="<?php if (is_page('Contact Us')) { echo 'width: 870px;'; } ?>">
于 2013-10-08T12:11:02.477 回答
0

您在联系我们+后面缺少一个 )

固定的线:

<div class="content" style="<?php if (is_page('Contact Us')){ echo 'width: 870px;'; } ?>">
于 2013-10-08T12:12:24.110 回答
0
<div class="content" style="<?php if (is_page('Contact Us')){ echo 'width: 870px;'; } ?>">
                                                           ^  
                                                           |

缺少括号...

谢谢。

于 2013-10-08T12:35:53.637 回答