Skip to content

Instantly share code, notes, and snippets.

@About2git
Forked from srikat/functions.php
Last active August 29, 2015 14:15
Show Gist options
  • Save About2git/4f5511b64bdb2e6fe7cb to your computer and use it in GitHub Desktop.
Save About2git/4f5511b64bdb2e6fe7cb to your computer and use it in GitHub Desktop.
How to display only the Title and Featured Image for Posts in Genesis.
<?php
//* Do NOT include the opening php tag
/**
* Featured Image linking to Post's single page.
*/
function sk_do_post_image() {
$image_args = array(
'size' => 'full',
'attr' => array(
'class' => 'alignleft',
)
);
// Get the featured image HTML
$image = genesis_get_image( $image_args );
echo '<a rel="bookmark" href="'. get_permalink() .'">'. $image .'</a>';
}
add_action( 'genesis_before_entry', 'sk_set_posts_display' );
/**
* Show Title and Featured image for all Posts. Featured image is not linked to or dependent on Content Archive theme settings
*
* Context: Archive and Search result pages.
*
* @author Sridhar Katakam
* @link http://sridharkatakam.com/display-title-featured-image-posts-genesis/
*/
function sk_set_posts_display() {
if ( ! ( is_archive() || is_search() ) ) {
return;
}
//* Remove the post info
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
//* Remove the post content
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
remove_action( 'genesis_entry_content', 'genesis_do_post_content_nav', 12 );
remove_action( 'genesis_entry_content', 'genesis_do_post_permalink', 14 );
//* Remove the post thumbnail coming from Content Archives theme settings
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
//* Add the post thumbnail
add_action( 'genesis_entry_content', 'sk_do_post_image' );
//* Remove the post meta
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment