WordPress if condition to add style to 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:

Read More
<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:xampphtdocswpaacowp-contentthemesaaco-themeindex.php on line 4

Related posts

Leave a Reply

4 comments

  1. you are missing a ) behind Contact Us+

    fixed line:

    <div class="content" style="<?php if (is_page('Contact Us')){ echo 'width: 870px;'; } ?>">
    
  2. Looks like you have a typo in your code. You’re missing a ) in your if statement. You want that line to be:

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