WordPress.org

Ready to get started?Download WordPress

Forums

No Sidebar PHP throwing off the text (9 posts)

  1. Resobaso
    Member
    Posted 1 year ago #

    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(); ?>
  2. johnbhartley
    Member
    Posted 1 year ago #

    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.

  3. 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.

  4. Resobaso
    Member
    Posted 1 year ago #

    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/

  5. johnbhartley
    Member
    Posted 1 year ago #

    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.

  6. Resobaso
    Member
    Posted 1 year ago #

    Ah, so create a CSS for

    No Sidebar PHP?

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

  7. johnbhartley
    Member
    Posted 1 year ago #

    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.

  8. Resobaso
    Member
    Posted 1 year ago #

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

    Thank you for the help!

  9. johnbhartley
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic