WordPress.org

Forums

How to Change Two-Column Blog to One-Column (1 post)

  1. jaeeun
    Member
    Posted 1 year ago #

    Hi,

    I'm redoing this page so as to make the two column layout to one column layout;

    http://www.regasstudio.com/blog/

    I played with <?php if (have_posts()) : while(have_posts()) : $i++; if(($i % 2) == 0) : $wp_query->next_post(); else : the_post(); ?> and `<?php
    if ($p == 1) break;
    endforeach; ?>`, but I can't figure it out.

    This is the whole code;

    <?php
    /*
    Template Name: Blog
    
    <li class="result <?php $k = $style_index % $styles_count; echo "$style_classes[$k]"; $style_index++; ?>">
    	<a href="javascript: alert('show spreads');">
    		<?php
    		$custom_field_data = get_post_meta($post->ID, 'press_cover', false);
    		if( !empty($custom_field_data[0]) ) { ?>
    			<img src="<?php echo wp_get_attachment_url($custom_field_data[0]); ?>" border="0" />
    		<?php } else { ?>
    			<img src="<?php bloginfo('template_url'); ?>/images/regas_logo.gif" width="175" border="0" />
    		<?php }?>
    	</a>
    
    	<p class="item_name"><?php echo get_post_meta($post->ID, 'press_name', true); ?></p>
    	<p class="item_date"><?php echo get_post_meta($post->ID, 'press_date', true); ?></p>
    </li>
    
    */
    get_header(); ?>
    
    	<div id="container" class="blog">
    		<div id="content">
    
    			<div id="" class="highlight_area">
    
    				<h1 class="header"><a href="/blog/"><span>Regas Paper Log</span></a></h1>
    
    				<?php
    					wp_reset_query();
    					$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    					$args=array(
    						'post_type'=>'post',
    						'order' => 'DESC',
    						'posts_per_page' => '4',
    						'paged' => $paged
    					);
    					query_posts($args);
    				?>
    				<div class="posts">
    
    					<div class="col_1">
    					<?php if (have_posts()) : while(have_posts()) : $i++; if(($i % 2) == 0) : $wp_query->next_post(); else : the_post(); ?>
    
    						<div id="post-<?php the_ID(); ?>" class="post left">
    							<?php
    								if(get_cfm('Blog Photos')):
    								$p = 0;
    							?>
    								<?php foreach(get_cfm('Blog Photos') as $image): $p++;?>
    								<div class="post_photo">
    									<a href="<?php the_permalink(); ?>"><img src="<?php echo $image->url; ?>" width="383" alt="<?php echo $image->alt; ?>" /></a>
    								</div>
    								<?php
    								if ($p == 1) break;
    								endforeach; ?>
    							<?php endif; ?>
    							<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    							<p class="post_date"><?php the_time('F j, Y'); ?></p>
    							<hr />
    
    						</div><!-- .post -->
    
    					<?php endif; endwhile; else: ?>
    						<div>Alternate content</div>
    					<?php endif; ?>
    					</div><!-- .col_1 -->
    
    					<?php $i = 0; rewind_posts(); ?>
    
    					<div class="col_2">
    					<?php if (have_posts()) : while(have_posts()) : $i++; if(($i % 2) !== 0) : $wp_query->next_post(); else : the_post(); ?>
    
    						<div id="post-<?php the_ID(); ?>" class="post right">
    							<?php
    								if(get_cfm('Blog Photos')):
    								$p = 0;
    							?>
    								<?php foreach(get_cfm('Blog Photos') as $image): $p++;?>
    								<div class="post_photo">
    									<a href="<?php the_permalink(); ?>"><img src="<?php echo $image->url; ?>" width="383" alt="<?php echo $image->alt; ?>" /></a>
    								</div>
    								<?php
    								if ($p == 1) break;
    								endforeach; ?>
    							<?php endif; ?>					
    
    							<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    							<p class="post_date"><?php the_time('F j, Y'); ?></p>
    							<hr />
    						</div><!-- .post -->
    
    					<?php endif; endwhile; else: ?>
    						<div>Alternate content</div>
    					<?php endif; ?>
    					</div><!-- .col_2 -->
    
    					<?php if (  $wp_query->max_num_pages > 1 ) : ?>
    					<div id="nav-below" class="navigation">
    						<div class="nav-next"><?php next_posts_link( __( '<span>next</span>', 'twentyten' ) ); ?></div>
    						<div class="nav-previous"><?php previous_posts_link( __( '<span>previous</span>', 'twentyten' ) ); ?></div>
    					</div><!-- #nav-below -->
    					<?php endif; ?>
    
    					<div class="clear"></div>
    				</div> <!-- # -->
    
    				<div class="clear"></div>
    			</div> <!-- # -->
    
    		</div><!-- #content -->
    	</div><!-- #container -->
    
    <?php get_footer(); ?>

    Please help!

    Thanks,
    Jaeeun

Topic Closed

This topic has been closed to new replies.

About this Topic