Last active
August 17, 2017 16:50
-
-
Save robincornett/42735823a27e6833bd2f to your computer and use it in GitHub Desktop.
Sample simple shop setup with a flexible grid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Archive page for products (custom post type). | |
* | |
*/ | |
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); | |
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 ); | |
remove_action( 'genesis_entry_footer', 'genesis_post_meta' ); | |
add_filter( 'genesis_pre_get_option_content_archive', 'rgc_do_full_content' ); | |
function rgc_do_full_content() { | |
return 'full'; | |
} | |
add_filter( 'genesis_pre_get_option_content_archive_limit', 'rgc_no_content_limit' ); | |
function rgc_no_content_limit() { | |
return '0'; | |
} | |
add_filter( 'post_class', 'rgc_grid_post_class' ); | |
function rgc_grid_post_class( $classes ) { | |
global $wp_query; | |
if ( ! $wp_query->is_main_query() ) { | |
return $classes; | |
} | |
$term = $wp_query->get_queried_object(); | |
$layout = genesis_site_layout( $term ); | |
$number = 2; | |
$column_class = 'one-half'; | |
if ( in_array( $layout, array( __genesis_return_sidebar_content(), __genesis_return_content_sidebar() ) ) ) { | |
$number = 3; | |
$column_class = 'one-third'; | |
} | |
elseif ( __genesis_return_full_width_content() === $layout ) { | |
$number = 4; | |
$column_class = 'one-fourth'; | |
} | |
$classes[] = 'grid ' . $column_class; | |
if ( 0 == $wp_query->current_post % $number ) { | |
$classes[] = 'first'; | |
} | |
return $classes; | |
} | |
add_action( 'genesis_entry_header', 'rgc_posts_grid', 5 ); | |
function rgc_posts_grid() { | |
global $post; | |
if ( $image = genesis_get_image( 'format=url&size=product' ) ) { | |
printf( '<div class="grid-image"><a href="%s" target="_blank" rel="bookmark"><img src="%s" alt="%s" class="aligncenter" /></a></div>', get_permalink(), $image, the_title_attribute( 'echo=0' ) ); | |
} | |
else { | |
printf( '<div class="grid-image"><a href="%s" target="_blank" rel="bookmark"><img src="%s" alt="%s" class="aligncenter" /></a></div>', get_permalink(), get_bloginfo( 'stylesheet_directory' ) . '/images/blank.jpg', the_title_attribute( 'echo=0' ) ); | |
} | |
} | |
genesis(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Grid | |
--------------------------------------------- */ | |
.entry.grid { | |
margin-bottom: 24px; | |
padding: 24px; | |
border: 1px solid #ddd; | |
border-radius: 0; | |
font-size: 16px; | |
text-align: center; | |
} | |
.grid .entry-title { | |
font-size: 24px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment