WordPress.org

Support

Support » Themes and Templates » 2 or 3 column grid layout for Twenty Twelve

2 or 3 column grid layout for Twenty Twelve

Viewing 1 replies (of 1 total)
  • hey diablo
    this is a custom category page i created in my twenty twelve child theme, using the 4 columns layout. basically you need to place Michael’s code in between the original theme’s code.
    hope that helps, but if you do custom theme stuff, i’d suggest you read manuals and tutorials on how to read WP code – it’s quite intuitive after you get the hang of it.

    <?php
    /**
     * The template for displaying Custom Category page
     *
     * Used to display archive-type pages for posts in a category.
     *
     * @link http://codex.wordpress.org/Template_Hierarchy
     *
     * @package WordPress
     * @subpackage Twenty_Twelve
     * @since Twenty Twelve 1.0
     */
    
    get_header(); ?>
    
    	<section id="primary" class="site-content">
    		<div id="content" role="main">
    
    	<?php
    	$num_cols = 4; // set the number of columns here
    	if (have_posts()) : ?>
    			<header class="entry-header">
    				<h1 class="entry-title"><?php printf( '%s', '<span>' . single_cat_title( '', false ) . '</span>' ); ?></h1>
    
    			<?php if ( category_description() ) : // Show an optional category description ?>
    				<div class="archive-meta"><?php echo category_description(); ?></div>
    			<?php endif; ?>
    			</header><!-- .archive-header -->
    
    		<?php
    		for ( $i=1 ; $i <= $num_cols; $i++ ) :
    			echo '<div id="col-'.$i.'" class="col">';
    			$counter = $num_cols + 1 - $i;
    			/* Start the Loop */
    			while (have_posts()) : the_post();
    				if( $counter%$num_cols == 0 ) :
    
    				/* Include the post format-specific template for the content. If you want to
    				 * 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() );
    
    				endif;
    				$counter++;
    			endwhile;
    			rewind_posts();
    			echo '</div>'; //closes the column div
    		endfor;
    		?>
    
    		<?php
    
    			twentytwelve_content_nav( 'nav-below' );
    			?>
    
    		<?php else : ?>
    			<?php get_template_part( 'content', 'none' ); ?>
    		<?php endif; ?>
    
    		</div><!-- #content -->
    	</section><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
Viewing 1 replies (of 1 total)
  • The topic ‘2 or 3 column grid layout for Twenty Twelve’ is closed to new replies.