For some reasons you may want to remove date from posts but if you remove date from posts like news article and announcements then it will lead confusion to your readers. So you may like to remove post dates from particular category only. For example, Lets say you have a category for tutorials which are timeless contents, So you don’t want to show date on them.
Here is a little trick you can implement on Genesis Framework by which the dates will be shown only to category you have mentioned.
First you need to find category ID’s of the category you want to remove dates. Here is a tutorial to find Category ID on WordPress.
Paste the following code at the end of your Genesis Child Theme’s functions.php
file (exclude <?php
tag at the beginning)
<?php
//* Do NOT include the opening php tag
//* Customize the entry meta in the entry header */
add_filter( 'genesis_post_info', 'post_info_filter' );
function post_info_filter($post_info) {
if( in_category( array('cat-1','cat-2') )) {
$post_info = 'Posted by [post_author_posts_link] [post_comments] [post_edit]';
}
else {
$post_info = '[post_date] by [post_author] [post_comments] [post_edit]';
}
return $post_info;
}
In above code change cat-1
and cat-2
with the category id’s you found previously.
The above code excludes date and outputs author name with link and comments count for posts inside categories mentioned.
Posts from other categories will be having date in post info. If you want to remove date on single category only then remove the second category id from the code.
You may want to remove date from all category but except few. In that case use the following code.
<?php
//* Do NOT include the opening php tag
//* Customize the entry meta in the entry header */
add_filter( 'genesis_post_info', 'post_info_filter' );
function post_info_filter($post_info) {
if( !in_category( array('cat-1','cat-2') )) {
$post_info = 'Posted by [post_author_posts_link] [post_comments] [post_edit]';
}
else {
$post_info = '[post_date] by [post_author] [post_comments] [post_edit]';
}
return $post_info;
}
Above code removes date from all the categories except the posts in category mentioned. This is a inverse function of first code.
Hope you found that useful. Hit me through comments if you are facing any problems.