• So I am currently developing a theme for the company I work for and everything is working fine but for some reason when I click on the archives link the containing div that is centered on every page (but the archives page) is flush left. Everything else works correctly except for the fact that the page is not centered. Everything is contained in a div called #wrap which as the following code in style.css:

    #wrap {
    		margin: 0 auto !important;
    		width: 960px;
    		padding: 0;
    		overflow: auto;
    		}

    here is the code on the archives.php file (everything is wrapped in #wrap which opens in the header):

    <?php get_header(); ?>
    
    	<div class="entry">
    		<?php if ( have_posts() ) : ?>
    			<h1 class="entry-title">
    					<?php
    						if ( is_day() ) :
    							printf( __( 'Daily Archives: %s' ), get_the_date() );
    
    						elseif ( is_month() ) :
    							printf( __( 'Monthly Archives: %s' ), get_the_date( _x( 'F Y', 'monthly archives date format' ) ) );
    
    						elseif ( is_year() ) :
    							printf( __( 'Yearly Archives: %s'), get_the_date( _x( 'Y', 'yearly archives date format' ) ) );
    
    						else :
    							_e( 'Archives' );
    
    						endif;
    					?>
    				</h1>
    
    				<?php
    					// Start the Loop.
    					while ( have_posts() ) : the_post();
    
    						/*
    						 * Include the post format-specific template for the content. If you want to
    						 * use this in a child theme, then include a file called called content-___.php
    						 * (where ___ is the post format) and that will be used instead.
    						 */
    						get_template_part( 'content', get_post_format() );
    
    					endwhile;
    					?>
    					<!--Previous and Next -->
    			<div id="previous-next">
    
    				<div class="previous">
    					<p><?php next_posts_link('Previous Entries') ?></p>
    				</div>
    
    				<div class="next">
    					<p><?php previous_posts_link('Next Entries') ?></p>
    				</div>
    
    			</div>
    			<!--Previous and Next End-->
    			<?php
    
    				else :
    					// If no content, include the "No posts found" template.
    					get_template_part( 'content', 'none' );
    
    				endif;
    			?>
    
    	</div><!--.entry-->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    I am at a loss. Everything displays the same in every page except for the archives page.

    Any help on the matter would be appreciated.

Viewing 5 replies - 1 through 5 (of 5 total)
  • please post a live link to where the problem can be seen;
    formatting cannot be checked just from the codes alone.

    does your theme use body_class() and does it otherwise use any .archive formatting in the stylesheets?

    Thread Starter wlui

    (@wlui)

    You know what just asking about the body_class() made me wonder if that was the problem, and it was. Removing the body_clas() from my header.php file displays the archive properly.

    I am also having this issue. Is there a way to have archive.php centered without having to remove body_class()?

    Still haven’t found a solution, any ideas?

    I’ve dug a little deeper. Is there a way to remove a single class from body_class()?

    EDIT: Figured it out. Add the following to your functions.php.

    function remove_a_body_class($wp_classes)
    {
        foreach($wp_classes as $key => $value)
        {
            if ($value == 'date')
            {
                unset($wp_classes[$key]);
            }
        }
    
        return $wp_classes;
    }
    add_filter('body_class', 'remove_a_body_class', 20, 2);

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Archives Page not centered’ is closed to new replies.