Support » Themes and Templates » No Sidebar PHP throwing off the text

  • So I had finally found a way to remove the side bar from particular Pages but it seems in doing so, it completely throws off the alignment of the text.

    Any tips?

    Example: http://www.resowalkthroughs.com/contact

    <?php
    /*
    Template Name: No Sidebar
    */
    ?>
    
    <?php get_header(); ?>
    
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <div style="width:850px !important;">
    
    <?php the_content('
    
    Read the rest of this page ยป</p>'); ?> <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?> <?php endwhile; else: ?> <p><?php _e('Sorry, no posts matched your criteria.'); ?></p> <?php endif; ?> </div> </div> <?php get_footer(); ?>
Viewing 8 replies - 1 through 8 (of 8 total)
  • What does the code for page.php look like. You most likely need to add a class or id to the div that wraps the content. Also, you should put that div outside of the loop.

    Moderator Mark Ratledge

    (@songdogtech)

    Forum Moderator

    Has nothing to do with adding a div; you missed a </div> closing tag. See [Invalid] Markup Validation of resowalkthroughs.com contact – W3C Markup Validator. Scroll down in the validation report to see line numbers and source code.

    Removed the contact form, to show my point, the text is waaay to close to the wall as opposed to normal posts.

    Example: http://www.resowalkthroughs.com/night-hatmovies-part-deux-abraham-lincoln-vampire-hunter/

    The difference here is that the content is wrapped in .art-post and .art-post-body, which gives it 7px margin and 10px padding, respectively. The div on the contact form with the Test Text inside has no class, and therefore no CSS to target that div with padding or margin. Follow the div structure of your other pages or write some custom CSS for the div your contact form is in.

    Ah, so create a CSS for

    No Sidebar PHP?

    Because outside of that, I’d think the normal page CSS would cover this.

    The way your usual post is setup is like this:

    <div class="art-content">
        <div class="art-Post">
           <div class="art-Post-body">
    
           </div>
        </div>
    </div>

    In the code you submitted earlier, your only div structure is

    <div style="width:850px !important;">
    </div>

    If you surround your content with the usual post structure, the CSS applied to posts will be applied to your contact form.

    Ill just put the side bar back and not mess with it.

    Thank you for the help!

    Try this:

    <?php
    /*
    Template Name: No Sidebar
    */
    ?>
    
    <?php get_header(); ?>
    
    <div class="art-content">
    <div class="art-Post">
    <div class="art-Post-body">
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <?php the_content(); ?> 
    
    <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>
    </div>
    </div>
    </div>
    <?php get_footer(); ?>

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘No Sidebar PHP throwing off the text’ is closed to new replies.