Skip to content

Instantly share code, notes, and snippets.

@jamiemitchell
Last active December 11, 2015 14:59
Show Gist options
  • Save jamiemitchell/4618318 to your computer and use it in GitHub Desktop.
Save jamiemitchell/4618318 to your computer and use it in GitHub Desktop.
Custom home page for Genesis Framework
<?php
add_action( 'genesis_before_loop', 'childtheme_welcome_widget' );
function childtheme_welcome_widget() {
dynamic_sidebar( 'Home Welcome' );
}
add_action( 'genesis_before_loop', 'childtheme_featured_artist' );
function childtheme_featured_artist() {
echo '<div class="home-top">';
echo '<h4 class="widgettitle">Featured Artist</h4>';
$args = array(
'cat' => '5',
'posts_per_page' => '1',
);
$tips = new WP_Query( $args );
if( $tips->have_posts() ):
echo '<div class="posts entry">';
while ( $tips->have_posts() ) : $tips->the_post();
echo '<a class="alignleft" href="' . get_permalink() .'" title="' . the_title_attribute( 'echo=0' ) . '">';
echo get_the_post_thumbnail($thumbnail->ID, 'featured-artist', array('class' => 'alignleft'));
echo '</a>';
echo '<h2 class="entry-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>';
echo '<div class="entry-content">';
the_content();
echo '</div>';
endwhile;
echo '</div>';
endif;
wp_reset_postdata();
echo '</div><!-- .home-top -->';
}
/* Modify the default loop
------------------------------------------------------------ */
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'custom_loop' );
function custom_loop() {
echo '<div class="home-middle">';
echo '<h4 class="widgettitle">Up and Coming</h4>';
global $paged;
$args = (array(
'category_name' => 'Events',
'category__not_in' => 5,
'order' => 'asc',
'order_by'=> 'title',
'paged' => $paged,
'posts_per_page' => 10
));
genesis_custom_loop( $args );
echo '</div><!-- .home-middle -->';
}
/* Add the featured image after post title
------------------------------------------------------------ */
add_action( 'genesis_before_post_title', 'childtheme_post_thumbnail' );
function childtheme_post_thumbnail() {
if ( has_post_thumbnail() ){
echo '<a class="alignleft" href="' . get_permalink() .'" title="' . the_title_attribute( 'echo=0' ) . '">';
echo get_the_post_thumbnail($thumbnail->ID, 'thumbnail', array('class' => 'alignleft'));
echo '</a>';
}
}
/* Read More changed
------------------------------------------------------------ */
add_filter( 'excerpt_more', 'child_read_more_link' );
add_filter( 'get_the_content_more_link', 'child_read_more_link' );
add_filter( 'the_content_more_link', 'child_read_more_link' );
function child_read_more_link() {
return '...<a class="more-link" href="' .
get_permalink() .
'" rel="nofollow">Read more</a>';
}
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment