• I’m trying to move a sidebar next to the list of archived blog posts on my archive page rather than underneath at the bottom of the page, but I can’t seem to figure out how to do so. Here is what it looks like now: http://www.brownstonelaw.com/archive/ and here is the PHP for the archive page template:

    <?php
    	/*
    	Template Name: Archives
    	*/
    
    	get_header(); 
    
    	global $wpdb;
    	//DISTINCT YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts
    	global $wpquery;
    if (is_paged()) :
            $fetch_archive = query_posts( "paged=".get_query_var('paged' ) );
        else :
            $fetch_archive = query_posts( "paged=1" );
        endif;
    
        $last_month = date( "m Y", strtotime( $wpquery->posts[0]->post_date ) );
    
    ?>
    
    <div id="title-container">
        <div class="title-block">
            <h2><?php the_title(); ?></h2>
        </div>
    </div>
    <div id="crumbs-container">
    	<?php ocmx_breadcrumbs(); ?>
    </div>
    <div id="content" class="clearfix">
        <div id="left-column">
        	<div class="archives">
                <ul class="archives_list">
                    <?php
                        foreach( $fetch_archive as $archive_data ) :
                            global $post;
                            $post = $archive_data;
                            $category_id = get_the_category( $archive_data->ID );
                            $this_category = get_category( $category_id[0]->term_id );
                            $this_category_link = get_category_link( $category_id[0]->term_id );
                            $link = get_permalink( $archive_data->ID );
                            $args  = array('postid' => $post->ID, 'width' => 50, 'height' => 50, 'exclude_video' => true, 'resizer' => 'thumbnail');
                            $image = get_obox_media($args); ?>
                            <li class="clearfix">
                            	<?php if(! (strpos($image, 'iframe') || strpos($image, 'object') ) ) : ?>
    	                            <div class="archive-post-image"><?php echo $image; ?></div>
                                <?php endif; ?>
                                <?php if(get_option("ocmx_meta_date") != "false"): ?>
                                <h5 class="date">
                                    <?php echo date_i18n('F dS', strtotime($archive_data->post_date)); ?>
                                </h5>
                                <?php endif; ?>
                                <h4 class="post-title"><a href="<?php echo get_permalink($archive_data->ID); ?>"><?php echo substr($archive_data->post_title, 0, 45); ?></a></h4>
                                <a href="<?php echo get_permalink($archive_data->ID); ?>/#comments" class="comment-count" title="Comment on <?php echo get_permalink($archive_data->post_title); ?>">
                                    <?php echo $archive_data->comment_count; ?> <?php _e("comments", "ocmx"); ?>
                                </a>
                                <span class="label">
                                    <a href="<?php echo $this_category_link; ?>" title="View all posts in <?php echo $this_category->name; ?>" rel="category tag"><?php echo $this_category->name; ?></a>
                                </span>
                            </li>
                        <?php
    
                        endforeach; ?>
    
                </ul>
            </div>
            <?php motionpic_pagination("clearfix", "pagination clearfix"); ?>
        </div>
    	<?php get_sidebar(); ?>
    </div>
    <?php get_footer(); ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,
    I don’t think it’s got to do with the html markup, but with the archive’s column spanning the fullwidth of the page.

    You’ve got:

    .sidebarnone #left-column {
    float: none;
    width: 100%;
    }

    In fact, the content-container has the .sidebarnone class. I think that, if you get rid of that class, things should work out as expected.

    Thread Starter rterry5

    (@rterry5)

    Hmm, that does work but it also adds extra space where the sidebar is supposed to be on every other page! :/

    Then you need to create a more specific template for this using the same markup (without the sidebarnone class) and a different name.

    I think this is a viable solution:
    The .sidebarnone class should be in the header template (I think). Therefore create a new header template and call it header-new.php or header-whatyoulike. Copy the contents of the original header.php file and delete the .sidebarnone class. Save the file and then, in archives.php, replace

    <?php get_header(); ?>

    with

    <?php get_header(‘new’); ?>

    The new header should apply only on the archives page

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Moving Sidebar Next to Archive’ is closed to new replies.