Forums

[resolved] Using a <div id with } else { (3 posts)

  1. FuxiAdmin
    Member
    Posted 2 years ago #

    Hello

    I posted this in another section but seem to get more luck in here.

    I'm attempting to give my single.php two options

    The second option is divided into two columns (widgets). I thought below would be the code to use but it is not working. Could somebody tell me what's wrong with it?

    <?php get_header(); ?>
    
    <div id="bigcolumn">
    
    <?php
    $post = $wp_query->post;
    if ( in_category('45') ) {
    include (TEMPLATEPATH . '/widgets/single2.html');
    } else {
    <div id="singleleftcolumn"><?php $sec = 1; include TEMPLATEPATH. '/widgets/leftmenu.html'; ?></div>
    <div id="singlerightcolumn"><?php $sec = 2; include TEMPLATEPATH. '/widgets/single.html'; ?></div>
    }
    ?>
    
    <div class="clear"></div>
    </div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    Thanks

  2. nerdanita
    Member
    Posted 2 years ago #

    You forgot to close the php tag before <div id=singleleftcolumn"> so it's not recognized as html. Try this:

    <?php get_header(); ?>
    
    <div id="bigcolumn">
    
    <?php
    $post = $wp_query->post;
    if ( in_category('45') ) {
        include (TEMPLATEPATH . '/widgets/single2.html');
    } else { ?>
        <div id="singleleftcolumn"><?php $sec = 1; include TEMPLATEPATH. '/widgets/leftmenu.html'; ?></div>
        <div id="singlerightcolumn"><?php $sec = 2; include TEMPLATEPATH. '/widgets/single.html'; ?></div>
    <?php
    }
    ?>
    
    <div class="clear"></div>
    </div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>
  3. FuxiAdmin
    Member
    Posted 2 years ago #

    This worked great, thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic