Community Forums › Forums › Archived Forums › General Discussion › Hide or remove post date on archive tempalte
Tagged: archive template, category template, functions.php, post-date
- This topic has 6 replies, 3 voices, and was last updated 7 years, 1 month ago by
cpaone.
-
AuthorPosts
-
January 28, 2016 at 12:40 pm #177752
cpaone
MemberI am trying to hide or remove the post date on my archive template, only (I want it to appear on the individual post). I only want the featured image and post title to appear on my archive.
I was able to hide all other elements except the post date with adding this code to my functions.php - does anyone know the proper hooks to remove the post date on the workstation pro theme?
// Remove Post Info, Post Meta from Archive Pages
http://designerbenchmark.com
function themeprefix_remove_post_meta() {
if (is_archive()) {
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
}
}
add_action ( 'genesis_entry_header', 'themeprefix_remove_post_meta' );January 28, 2016 at 5:19 pm #177780Brad Dalton
Participantadd_filter( 'genesis_post_info', 'sp_post_info_filter' ); function sp_post_info_filter($post_info) { if ( is_archive() ) { $post_info = 'by [post_author_posts_link] [post_comments] [post_edit]'; return $post_info; } }
Using a code editor, add the above PHP to the end of your child themes functions file. Change the conditional tag if needed.
January 28, 2016 at 6:32 pm #177785cpaone
Memberthanks for the reply but the above code suggested to add to the php functions file actually breaks the site?
January 28, 2016 at 6:42 pm #177786Brad Dalton
ParticipantThe code comes from StudioPress and has been used millions of times.
Did you add the code using FTP and a code editor?
I tested it and it does not break.
January 28, 2016 at 6:50 pm #177788cpaone
MemberThanks for testing.
I still get the same issue - a blank site
I copy/ pasted the code to the end of my child theme functions.php file, then uploaded it (as a replacement) via ftp - do you know what I might be doing wrong here? Appreciate the support
January 28, 2016 at 10:20 pm #177792Genesis Developer
MemberRemove the old code and try this one
add_filter( 'genesis_post_info', 'gd_post_info_filter' ); function gd_post_info_filter( $post_info ) { if ( is_archive() ) { $post_info = __( 'by' ) . ' [post_author_posts_link] [post_comments] [post_edit]'; } return $post_info; }
January 29, 2016 at 1:06 am #177799cpaone
MemberThanks for the help, both code samples helped me find the solution...
Turns out the 'sp_post_info_filter' was already in use earlier in the functions file and I did not see it (I am new to this). Here is what I ended up doing to get the results I wanted...
//* Customize the entry meta in the entry header (requires HTML5 theme support)
add_filter( 'genesis_post_info', 'sp_post_info_filter' );
function sp_post_info_filter($post_info) {
$post_info = '[post_date]';
if ( is_archive() ) {
$post_info = '';
}
return $post_info;
}// Remove Post excerpt, Post Meta from Archive Pages
add_action ( 'genesis_entry_header', 'themeprefix_remove_post_meta' );
function themeprefix_remove_post_meta() {
if (is_archive()) {
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
}
} -
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.