Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Robin's lazy grid layout
<?php
/**
* This file adds a front page. It forces the first post on the page to output
* as full content.
*
* @author Robin Cornett
* @package Genesis
* @subpackage Customizations
*
* source: http://sridharkatakam.com/display-full-post-content-first-post-category-pages-genesis/
*/
// Remove post image
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
//* Full content for first post in category pages
add_action( 'genesis_before_entry', 'rgc_first_post_content' );
function rgc_first_post_content() {
global $wp_query;
if ( ! is_paged() && $wp_query->current_post == 0 ) {
add_filter( 'genesis_pre_get_option_content_archive', 'rgc_do_full_content' );
add_filter( 'genesis_pre_get_option_content_archive_limit', 'rgc_no_content_limit' );
}
}
// Set the content archives to full
function rgc_do_full_content() {
return 'full';
}
// Make sure the content limit isn't set
function rgc_no_content_limit() {
return '0';
}
genesis();
<?php
// add this to your functions.php file but do not include the opening tag!
//* Add new image sizes
add_image_size( 'home-middle', 332, 190, TRUE ); // unnecessary if you are already using Metro Child theme
add_action( 'genesis_before_entry', 'rgc_grid_posts' );
function rgc_grid_posts() {
global $wp_query;
if ( is_singular() || is_post_type_archive() ) {
return;
}
if ( $wp_query->current_post != 0 || is_paged() || ! is_home() ) {
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
add_filter( 'post_class', 'rgc_grid_post_class' );
add_action( 'genesis_entry_header', 'rgc_posts_grid', 5 );
}
}
function rgc_grid_post_class( $classes ) {
global $wp_query;
if ( $wp_query->is_main_query() ) {
$classes[] = 'grid one-third';
if ( is_home() && ! is_paged() ) {
if ( 0 == ( $wp_query->current_post +2 ) % 3 ) {
$classes[] = 'first';
}
}
elseif ( 0 == $wp_query->current_post % 3 ) {
$classes[] = 'first';
}
}
return $classes;
}
function rgc_posts_grid() {
if ( $image = genesis_get_image( 'format=url&size=home-middle' ) ) {
printf( '<div class="grid-image"><a href="%s" rel="bookmark"><img src="%s" alt="%s" /></a></div>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
}
else {
printf( '<div class="grid-image"><a href="%s" rel="bookmark"><img src="%s" alt="%s" /></a></div>', get_permalink(), get_bloginfo( 'stylesheet_directory' ) . '/images/blank.jpg', the_title_attribute( 'echo=0' ) );
}
}
add_action( 'pre_get_posts', 'rgc_front_page_number_posts' );
function rgc_front_page_number_posts( $query ) {
if ( $query->is_home() && $query->is_main_query() && ! is_paged() ) {
$query->set( 'posts_per_page', 10 );
}
}
/* Grid -- styled to match Metro child theme
--------------------------------------------- */
.grid .entry-header {
margin: 0 10px 10px;
padding-bottom: 10px;
background: #fff;
}
.grid .entry-title,
.grid h2.entry-title a {
padding: 0;
background: none;
}
.grid .entry-title {
margin: 10px;
font-size: 18px;
line-height: 1.2;
text-transform: none;
}
.entry.grid {
margin-top: 24px;
margin-bottom: 24px;
padding-top: 10px;
padding-bottom: 0;
background: url(images/lines.png);
}
.grid-image {
overflow: hidden;
border: 10px white solid;
}
.grid img {
display: block;
float: none;
margin: 0 auto;
}
.grid a img:hover {
-webkit-transition: ease-out 8s;
-moz-transition: ease-out 8s;
-o-transition: ease-out 8s;
transition: ease-out 8s;
-webkit-transform: scale(1.2);
-moz-transform: scale(1.2);
-o-transform: scale(1.2);
transform: scale(1.2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment