WordPress.org

Ready to get started?Download WordPress

Forums

Custom Page Template Sidebar remnant (4 posts)

  1. EvyLHanson
    Member
    Posted 2 months ago #

    I just created a custom template to get rid of the sidebar on an inner page which worked successfully. However, any text I add is still behaving as if there is a sidebar there. Images span full width but text is being confined to the left side as if there is an "invisible" sidebar in place.

    To create the custom page I copied page.php and removed the sidebar reference, but I'm thinking something is left in there that's causing this to happen. Here's the code:

    /*
    Template Name: Custom
    */
    
    <?php get_header(); ?>
                   <div id="wrapper">
                      <div id="content">
                            <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
                            <?php
                            if (has_post_thumbnail()) :
                              echo '<div class="thumbnail-p">';
                                the_post_thumbnail('full');
                              echo '</div>';
                            else:
                              echo "";
                            endif;
                            ?>
    
                            <h1 class="page-title"><?php the_title(); ?></h1>
                            <?php the_content(); ?>
                            <?php endwhile;
                             else: ?>
                             <p>Sorry, no posts matched your criteria.</p>
                             <?php endif; ?>
                      </div><!--</#content>-->
                       <?php dynamic_sidebar('page-bottom'); ?>
                </div><!--</#wrapper>-->
    <?php get_footer(); ?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

    I tried removing : <?php dynamic_sidebar('page-bottom'); ?> but that removes the background and still leaves the same issue with the text. Can someone please help?

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 months ago #

    you will likely need to adjusts some styles based on the custom template file name related CSS class (only if your theme uses body_class() http://codex.wordpress.org/Function_Reference/body_class#Page )

    what theme are you working with?

    can you provide a link to a page with the custom template?

  3. EvyLHanson
    Member
    Posted 2 months ago #

    It's a custom theme (I didn't actually design the site, just making some updates to it). Here's a link to the page http://www.desertalarm.com/lifesentry-help-touch-button/

    As you can see all the text is pushed over to the left while images are spanning full width. Appreciate any input you can provide!

  4. alchymyth
    The Sweeper & Moderator
    Posted 2 months ago #

    a:
    please wrap the template name at the top of the template into php tags (right now it is showing at the top of the web page);

    <?php /*
    Template Name: Custom
    */ /.

    b:
    unfortunately, the theme does not use body_class() so you don't have an easy specific CSS way of only formatting things in a page using the template.

    c:
    one way to add a template specific CSS class might be by editing this line:
    <div id="wrapper">
    to:
    <div id="wrapper" class="custom">

    d:
    then add some styles like:
    .custom #content { width: 100%; }

Reply

You must log in to post.

About this Topic