Skip to content

Instantly share code, notes, and snippets.

@paaljoachim
Last active February 13, 2016 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save paaljoachim/3e68c7c09340f7c4b596 to your computer and use it in GitHub Desktop.
Save paaljoachim/3e68c7c09340f7c4b596 to your computer and use it in GitHub Desktop.
Post preview and posts - Genesis code snippets
// Customize the post meta "FILED UNDER: -category name-" categories text and below the post preview in a blog page and change it at the bottom of a post.
// http://wordpress.stackexchange.com/questions/50961/removing-post-meta-from-category-pages */
//
add_filter( 'genesis_post_meta', 'sp_post_meta_filter' );
function sp_post_meta_filter($post_meta) {
if ( !is_page() ) {
if (is_archive() ) $post_meta = '';
else $post_meta = '[post_categories before="Categories: "] [post_tags before="Keywords: "]';
return $post_meta;
}}
// A last updated date seen below the original post date.
//
add_filter( 'genesis_post_info', 'sk_post_info_filter' );
function sk_post_info_filter($post_info) {
if (get_the_modified_time() != get_the_time()) {
$post_info = $post_info . '<br/>Last updated on: ' . the_modified_date('j F, Y', '', '', false);
}
return $post_info;
}
// Adjust post meta in entry header AND change comments text in comments button
// http://wpspeak.com/remove-post-date-in-genesis-framework/
//
add_filter( 'genesis_post_info', 'post_info_filter' );
function post_info_filter($post_info) {
$post_info = '[post_date] By [post_author_posts_link] [post_comments zero="Add a Comment" one="1 Comment" more="% Comments"] [post_edit]';
return $post_info;
}
// Modify the Genesis content limit read more link - Genesis Settings page - Display post content certain amount of characters. I selected 175.
//
add_filter( 'get_the_content_more_link', 'sp_read_more_link' );
function sp_read_more_link() {
return '... <a class="more-link" href="' . get_permalink() . '">[Continue reading..]</a>';
}
// On your blog or home page show Post with most comments first.
// http://wpsites.net/wordpress-tips/show-posts-with-most-comments-first-on-your-home-page/
//
add_action( 'pre_get_posts', 'wpsites_show_posts_most_comments_first' );
function wpsites_show_posts_most_comments_first( $query ) {
if ( $query->is_home() && $query->is_main_query() && !is_admin() ) {
$query->set( 'orderby', 'comment_count' );
}
}
//* Remove page titles from all single posts & pages (requires HTML5 theme support)
add_action( 'get_header', 'child_remove_titles' );
function child_remove_titles() {
if ( is_singular() ){
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment