dongyanghan0556 2013-10-08 12:07
浏览 24
已采纳

Wordpress如果条件为div添加样式

i have a single theme i use in my wordpress but i want to change the css of my ' contents div ' manually using php this is currently what i'm trying to do:

<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(); ?>

as you can see this line:

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

is where i'm trying to change the size of the div to 100% using php but i keep getting this error:

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

4条回答 默认 最新

  • duanhe0817825 2013-10-08 12:12
    关注

    you are missing a ) behind Contact Us+

    fixed line:

    <div class="content" style="<?php if (is_page('Contact Us')){ echo 'width: 870px;'; } ?>">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思