Created
October 7, 2016 03:41
-
-
Save anilmeena/d5337629c546f6186b19229269b8afa4 to your computer and use it in GitHub Desktop.
Genesis Custom Home Page Template
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 | |
/* Genesis Custom Home Page Template */ | |
function child_grid_loop_helper() { | |
genesis_grid_loop( array( | |
'features' => 2, | |
'feature_image_size' => 'child_full', | |
'feature_image_class' => 'aligncenter post-image', | |
'feature_content_limit' => 0, | |
'grid_image_size' => 0, | |
'grid_content_limit' => 0, | |
'more' => __( '[Continue reading...]', 'genesis' ), | |
'posts_per_page' => 10, | |
) ); | |
} | |
remove_action( 'genesis_loop', 'genesis_do_loop' ); | |
add_action( 'genesis_loop', 'child_grid_loop_helper' ); | |
function child_switch_content() { | |
remove_action('genesis_post_content', 'genesis_grid_loop_content'); | |
add_action('genesis_post_content', 'child_grid_loop_content'); | |
add_action('genesis_after_post', 'child_grid_divider'); | |
add_action('genesis_before_post_title', 'child_grid_loop_image'); | |
} | |
add_action('genesis_before_post', 'child_switch_content'); | |
function child_grid_loop_content() { | |
global $_genesis_loop_args; | |
if ( in_array( 'genesis-feature', get_post_class() ) ) { | |
if ( $_genesis_loop_args['feature_image_size'] ) { | |
printf( '<a href="%s" title="%s">%s</a>', get_permalink(), the_title_attribute('echo=0'), genesis_get_image( array( 'size' => $_genesis_loop_args['feature_image_size'], 'attr' => array( 'class' => esc_attr( $_genesis_loop_args['feature_image_class'] ) ) ) ) ); | |
} | |
the_excerpt(); | |
$num_comments = get_comments_number(); | |
if ($num_commets == '1') $comments = '<span>'.$num_comments.'</span> comment'; | |
else $comments = '<span>'.$num_comments.'</span> comments'; | |
echo '<p class="to_comments"><span class="bracket">{</span><a href="'.get_permalink().'/#comments" rel="nofollow">'.$comments.'</a><span class="bracket">}</span></p>'; | |
} | |
else { | |
the_excerpt(); | |
$num_comments = get_comments_number(); | |
if ($num_commets == '1') $comments = $num_comments.' comment'; | |
else $comments = $num_comments.' comments'; | |
echo '<p class="more"><a class="comments" href="'.get_permalink().'/#comments">'.$comments.'</a> <a href="'.get_permalink().'">Read the full article &raquo;</a></p>'; | |
} | |
} | |
function child_grid_loop_image() { | |
if ( in_array( 'genesis-grid', get_post_class() ) ) { | |
global $post; | |
echo '<p class="thumbnail"><a href="'.get_permalink().'">'.get_the_post_thumbnail($post->ID, 'child_thumbnail').'</a></p>'; | |
} | |
} | |
function child_grid_divider() { | |
global $loop_counter, $paged; | |
if ((($loop_counter + 1) % 2 == 0) && !($paged == 0 && $loop_counter < 2) ) echo '<hr />'; | |
} | |
genesis(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment