Skip to content

Instantly share code, notes, and snippets.

@robincornett
Last active December 20, 2015 01:39
Show Gist options
  • Save robincornett/6051023 to your computer and use it in GitHub Desktop.
Save robincornett/6051023 to your computer and use it in GitHub Desktop.
New blog template using featured images (for Genesis 2.0/HTML5)
<?php
/**
* Template Name: Featured Image Blog Template
* Description: Use with query_args to show the featured medium image only of all called posts/pages.
* @author Robin Cornett
* @package Lookout 2013
*/
remove_action ('genesis_loop', 'genesis_do_loop'); // Remove the standard loop
add_action( 'genesis_loop', 'genesis_standard_loop', 5 ); // show the editor content
add_action( 'genesis_loop', 'rgc_do_loop' ); // Add custom loop
function rgc_do_loop() {
if ( 1 >= get_query_var( 'paged' ) ) {
add_action( 'genesis_loop', 'genesis_standard_loop', 5 );
}
global $post;
// arguments, adjust as needed
$args = wp_parse_args(
genesis_get_custom_field( 'query_args' ),
array(
'post_type' => 'post',
'post_status' => 'publish',
'paged' => get_query_var( 'paged' ) )
);
global $wp_query;
$wp_query = new WP_Query( $args );
if ( have_posts() ) :
while ( have_posts() ) : the_post();
echo '<div class="rgc-featured-image">';
echo '<h3><a href="' . get_permalink() . '"> ' . get_the_title() . ' </a> </h3>'; // show the title
echo '<a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '">'; // Original Grid
echo get_the_post_thumbnail( $post->ID, 'medium' );
echo '</a>';
echo '</div>';
endwhile;
do_action( 'genesis_after_endwhile' );
endif;
wp_reset_query();
}
genesis();
/** Include this in your style.css */
/*
Featured Image Blog Template Page
---------------------------------------------------------------------------------------------------- */
.rgc-featured-image h3,
.rgc-featured-image h3 a {
font-size: 14px;
color: #555;
font-family: 'proxima_nova_ltlight', sans-serif;
}
.rgc-featured-image a img {
-moz-transition: all 0.2s ease-in-out;
-webkit-transition: all 0.2s ease-in-out;
border: 10px solid #f5f5f5;
transition: all 0.2s ease-in-out;
}
.rgc-featured-image a img:hover{
border: 10px solid #eee;
}
.rgc-featured-image {
float: left;
text-align: center;
margin-bottom: 3rem;
margin-bottom: 30px;
padding: 0 10px;
}
.content-sidebar .rgc-featured-image,
.sidebar-content .rgc-featured-image {
width: 50%;
}
.full-width-content .rgc-featured-image {
width: 33%;
}
@media only screen and (max-width: 1023px) {
.full-width-content .rgc-featured-image {
width: 50%;
}
}
@media only screen and (max-width: 767px) {
.content-sidebar .rgc-featured-image,
.sidebar-content .rgc-featured-image,
.full-width-content .rgc-featured-image {
width: 100%;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment