About Sridhar Katakam
I am an independent WordPress web consultant with 10 years of experience in WordPress theme installation, customization, administration, maintenance, support, documentation, troubleshooting and PSD/design to WP.
Genesis and WordPress Tutorials
Session expired
Please log in again. The login page will open in a new tab. After logging in you can close it and return to this page.
Hi,
I would like to use the hooks plug-in. Not very good with coding – would this be correct?
genesis_after_post_title hook
<?php
if (get_the_modified_time() != get_the_time()) {
$post_info = $post_info . 'Last updated on: ‘ . the_modified_date(‘F j, Y’, ”, ”, false);
}
return $post_info;
?>
As far as I know, it is not possible to add filters using the Simple Hooks plugin.
ok.
Hi,
I posted the code as in in functions.php. No – change. Only shows the published date – even though I updated post. Using 16-9 theme.
Thanks
T
Using Sixteen Nine or Sixteen Nine Pro?
Pro
I’ve just activated Sixteen Nine Pro on my test site, edited a Post, added some content and updated it. Reloaded the site’s homepage and I can see Last Updated date just fine.
Screenshot:
http://i.imgur.com/hAb0E5c.png
Screenshot of functions.php: http://i.imgur.com/e3ScZsZ.png
That’s really strange. I added it exactly as per your screen shot:
Exactly after last widget:
//* Register widget areas
genesis_register_sidebar( array(
‘id’ => ‘after-entry’,
‘name’ => __( ‘After Entry’, ‘sixteen-nine’ ),
‘description’ => __( ‘This is the widget that appears after the entry on single posts.’, ‘sixteen-nine’ ),
) );
//* ADDITION: Add last updated date to the post info in entry header (requires HTML5 theme support)
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 . ‘Last updated on: ‘ . the_modified_date(‘F j, Y’, ”, ”, false);
}
return $post_info;
}
And then just updated this post and not showing an update.
http://pitstop.oncourse4wd.com/2014/modifications-2/examples-of-modifications-which-affect-off-road-capability-hr-radio/
If you would like me to take a look inside to troubleshoot, send me WP and FTP logins via http://www.sridharkatakam.com/contact/
hey awesome stuff,
i am not good in php hence need some help
i was working on modified date but what i want is :
1. published date should be default format eg month date year
2. updated date should be Using “human time “. eg 6days ago
3. comments should be Using “human time “. eg 6days ago
i would like to know how can i implement above eg using your method.
currently i am using following code just for comments, it is from one of the free plugin.
please advice
//* Function: Display Comment Relative Date (Today/Yesterday/Days Ago/Weeks Ago)
add_filter('get_comment_date', 'relative_comment_date', 999);
function relative_comment_date($current_dateformat, $display_ago_only = 1) {
global $comment;
$comment_date = $comment->comment_date;
if(gmdate('Y', current_time('timestamp')) != mysql2date('Y', $comment_date, false)) {
return $current_dateformat;
}
$day_diff = (gmdate('z', current_time('timestamp')) - mysql2date('z', $comment_date, false));
if($day_diff < 0) { $day_diff = 32; }
if($day_diff == 0) {
return __('Today', 'wp-relativedate');
} elseif($day_diff == 1) {
return __('Yesterday', 'wp-relativedate');
} elseif ($day_diff < 7) {
if($display_ago_only) {
return sprintf(_n('%s day ago', '%s days ago', $day_diff, 'wp-relativedate'), number_format_i18n($day_diff));
} else {
return $current_dateformat.' ('.sprintf(_n('%s day ago', '%s days ago', $day_diff, 'wp-relativedate'), number_format_i18n($day_diff)).')';
}
} elseif ($day_diff comment_date, false);
$date_today = gmdate('j-n-Y', $current_time);
$comment_date = mysql2date('j-n-Y', $comment->comment_date, false);
$time_diff = (strtotime($date_today_time) - strtotime($comment_date_time));
$format_ago = '';
if($comment_date == $date_today) {
if($time_diff < 60) {
$format_ago = sprintf(_n('%s second ago', '%s seconds ago', $time_diff, 'wp-relativedate'), number_format_i18n($time_diff));
} elseif ($time_diff < 3600) {
$format_ago = sprintf(_n('%s minute ago', '%s minutes ago', intval($time_diff/60), 'wp-relativedate'), number_format_i18n(intval($time_diff/60)));
} elseif ($time_diff < 86400) {
$format_ago = sprintf(_n('%s hour ago', '%s hours ago', intval($time_diff/3600), 'wp-relativedate'), number_format_i18n(intval($time_diff/3600)));
}
if($display_ago_only) {
return $format_ago;
} else {
return $current_timeformat.' ('.$format_ago.')';
}
} else {
return $current_timeformat;
}
}
Hi
I have been trying to get the to work and can’t. I copy and paste it into the function.php of my genesis child theme under the Register widget area but it doesn’t seem to be working. I cleared my site cache and purged my CDN but still nothing. Could you please help.
I follow you on twitter so if its not apparent what is wrong and you would be willing I could give you access to my site.
This is the code of my functions.php file of my child theme Minimum Pro
Thanks JEFF
'__return_false' ) );
//* Add support for custom header
add_theme_support( 'custom-header', array(
'width' => 320,
'height' => 60,
'header-selector' => '.site-title a',
'header-text' => false
) );
//* Add support for structural wraps
add_theme_support( 'genesis-structural-wraps', array(
'header',
'site-tagline',
'nav',
'subnav',
'home-featured',
'site-inner',
'footer-widgets',
'footer',
'featured'
) );
// Changing excerpt more
function new_excerpt_more($more) {
global $post;
return '…ID) . '">' . ' Read More »' . '';
}
add_filter('excerpt_more', 'new_excerpt_more');
/***************
*
* End of Edit by Jeff
*
****************/
//* Add support for 3-column footer widgets
add_theme_support( 'genesis-footer-widgets', 3 );
//* Unregister layout settings
genesis_unregister_layout( 'content-sidebar-sidebar' );
genesis_unregister_layout( 'sidebar-content-sidebar' );
genesis_unregister_layout( 'sidebar-sidebar-content' );
//* Unregister secondary sidebar
unregister_sidebar( 'sidebar-alt' );
//* Create portfolio custom post type
add_action( 'init', 'minimum_portfolio_post_type' );
function minimum_portfolio_post_type() {
register_post_type( 'portfolio',
array(
'labels' => array(
'name' => __( 'Portfolio', 'minimum' ),
'singular_name' => __( 'Portfolio', 'minimum' ),
),
'exclude_from_search' => true,
'has_archive' => true,
'hierarchical' => true,
'menu_icon' => get_stylesheet_directory_uri() . '/images/icons/portfolio.png',
'public' => true,
'rewrite' => array( 'slug' => 'portfolio' ),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'genesis-seo' ),
)
);
}
//* Remove site description
remove_action( 'genesis_site_description', 'genesis_seo_site_description' );
//* Reposition the primary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_nav' );
add_action( 'genesis_after_header', 'genesis_do_nav', 15 );
//* Reposition the secondary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_footer', 'genesis_do_subnav', 7 );
//* Reduce the secondary navigation menu to one level depth
add_filter( 'wp_nav_menu_args', 'minimum_secondary_menu_args' );
function minimum_secondary_menu_args( $args ){
if( 'secondary' != $args['theme_location'] )
return $args;
$args['depth'] = 1;
return $args;
}
//* Add the site tagline section
function minimum_site_tagline() {
printf( '', genesis_attr( 'site-tagline' ) );
genesis_structural_wrap( 'site-tagline' );
printf( '', genesis_attr( 'site-tagline-left' ) );
printf( '%s', genesis_attr( 'site-description' ), esc_html( get_bloginfo( 'description' ) ) );
echo '';
printf( '', genesis_attr( 'site-tagline-right' ) );
genesis_widget_area( 'site-tagline-right' );
echo '';
genesis_structural_wrap( 'site-tagline', 'close' );
echo '';
}
//* Modify the size of the Gravatar in the author box
add_filter( 'genesis_author_box_gravatar_size', 'minimum_author_box_gravatar' );
function minimum_author_box_gravatar( $size ) {
return 144;
}
//* Modify the size of the Gravatar in the entry comments
add_filter( 'genesis_comment_list_args', 'minimum_comments_gravatar' );
function minimum_comments_gravatar( $args ) {
$args['avatar_size'] = 96;
return $args;
}
//* Change the number of portfolio items to be displayed (props Bill Erickson)
add_action( 'pre_get_posts', 'minimum_portfolio_items' );
function minimum_portfolio_items( $query ) {
if ( $query->is_main_query() && !is_admin() && is_post_type_archive( 'portfolio' ) ) {
$query->set( 'posts_per_page', '6' );
}
}
//* Register widget areas
genesis_register_sidebar( array(
'id' => 'site-tagline-right',
'name' => __( 'Site Tagline Right', 'minimum' ),
'description' => __( 'This is the site tagline right section.', 'minimum' ),
) );
genesis_register_sidebar( array(
'id' => 'home-featured-1',
'name' => __( 'Home Featured 1', 'minimum' ),
'description' => __( 'This is the home featured 1 section.', 'minimum' ),
) );
genesis_register_sidebar( array(
'id' => 'home-featured-2',
'name' => __( 'Home Featured 2', 'minimum' ),
'description' => __( 'This is the home featured 2 section.', 'minimum' ),
) );
genesis_register_sidebar( array(
'id' => 'home-featured-3',
'name' => __( 'Home Featured 3', 'minimum' ),
'description' => __( 'This is the home featured 3 section.', 'minimum' ),
) );
genesis_register_sidebar( array(
'id' => 'home-featured-4',
'name' => __( 'Home Featured 4', 'minimum' ),
'description' => __( 'This is the home featured 4 section.', 'minimum' ),
) );
//* Register widget area
genesis_register_sidebar( array(
'id' => 'featured',
'name' => __( 'Featured', 'minimum' ),
'description' => __( 'This is the featured section.', 'minimum' ),
) );
/***************
*
* Edited by Jeff
*
****************/
//* Add last updated date to the post info in entry header (requires HTML5 theme support)
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 . 'Last updated on: ' . the_modified_date('F j, Y', '', '', false);
}
return $post_info;
}
/***************
*
* End Edit
*
****************/
//* Add the featured section
add_action( 'genesis_after_header', 'sk_featured' );
function sk_featured() {
if ( is_active_sidebar( 'featured' ) ) {
printf( '', genesis_attr( 'featured' ) );
genesis_structural_wrap( 'featured' );
genesis_widget_area( 'featured' );
genesis_structural_wrap( 'featured', 'close' );
echo '';
}
}
Didn’t Seem to post all of it
'__return_false' ) );
//* Add support for custom header
add_theme_support( 'custom-header', array(
'width' => 320,
'height' => 60,
'header-selector' => '.site-title a',
'header-text' => false
) );
//* Add support for structural wraps
add_theme_support( 'genesis-structural-wraps', array(
'header',
'site-tagline',
'nav',
'subnav',
'home-featured',
'site-inner',
'footer-widgets',
'footer',
'featured'
) );
// Changing excerpt more
function new_excerpt_more($more) {
global $post;
return '…ID) . '">' . ' Read More »' . '';
}
add_filter('excerpt_more', 'new_excerpt_more');
/***************
*
* End of Edit by Jeff
*
****************/
//* Add support for 3-column footer widgets
add_theme_support( 'genesis-footer-widgets', 3 );
//* Unregister layout settings
genesis_unregister_layout( 'content-sidebar-sidebar' );
genesis_unregister_layout( 'sidebar-content-sidebar' );
genesis_unregister_layout( 'sidebar-sidebar-content' );
//* Unregister secondary sidebar
unregister_sidebar( 'sidebar-alt' );
//* Create portfolio custom post type
add_action( 'init', 'minimum_portfolio_post_type' );
function minimum_portfolio_post_type() {
register_post_type( 'portfolio',
array(
'labels' => array(
'name' => __( 'Portfolio', 'minimum' ),
'singular_name' => __( 'Portfolio', 'minimum' ),
),
'exclude_from_search' => true,
'has_archive' => true,
'hierarchical' => true,
'menu_icon' => get_stylesheet_directory_uri() . '/images/icons/portfolio.png',
'public' => true,
'rewrite' => array( 'slug' => 'portfolio' ),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'genesis-seo' ),
)
);
}
//* Remove site description
remove_action( 'genesis_site_description', 'genesis_seo_site_description' );
//* Reposition the primary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_nav' );
add_action( 'genesis_after_header', 'genesis_do_nav', 15 );
//* Reposition the secondary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_footer', 'genesis_do_subnav', 7 );
//* Reduce the secondary navigation menu to one level depth
add_filter( 'wp_nav_menu_args', 'minimum_secondary_menu_args' );
function minimum_secondary_menu_args( $args ){
if( 'secondary' != $args['theme_location'] )
return $args;
$args['depth'] = 1;
return $args;
}
//* Add the site tagline section
function minimum_site_tagline() {
printf( '', genesis_attr( 'site-tagline' ) );
genesis_structural_wrap( 'site-tagline' );
printf( '', genesis_attr( 'site-tagline-left' ) );
printf( '%s', genesis_attr( 'site-description' ), esc_html( get_bloginfo( 'description' ) ) );
echo '';
printf( '', genesis_attr( 'site-tagline-right' ) );
genesis_widget_area( 'site-tagline-right' );
echo '';
genesis_structural_wrap( 'site-tagline', 'close' );
echo '';
}
//* Modify the size of the Gravatar in the author box
add_filter( 'genesis_author_box_gravatar_size', 'minimum_author_box_gravatar' );
function minimum_author_box_gravatar( $size ) {
return 144;
}
//* Modify the size of the Gravatar in the entry comments
add_filter( 'genesis_comment_list_args', 'minimum_comments_gravatar' );
function minimum_comments_gravatar( $args ) {
$args['avatar_size'] = 96;
return $args;
}
//* Change the number of portfolio items to be displayed (props Bill Erickson)
add_action( 'pre_get_posts', 'minimum_portfolio_items' );
function minimum_portfolio_items( $query ) {
if ( $query->is_main_query() && !is_admin() && is_post_type_archive( 'portfolio' ) ) {
$query->set( 'posts_per_page', '6' );
}
}
//* Register widget areas
genesis_register_sidebar( array(
'id' => 'site-tagline-right',
'name' => __( 'Site Tagline Right', 'minimum' ),
'description' => __( 'This is the site tagline right section.', 'minimum' ),
) );
genesis_register_sidebar( array(
'id' => 'home-featured-1',
'name' => __( 'Home Featured 1', 'minimum' ),
'description' => __( 'This is the home featured 1 section.', 'minimum' ),
) );
genesis_register_sidebar( array(
'id' => 'home-featured-2',
'name' => __( 'Home Featured 2', 'minimum' ),
'description' => __( 'This is the home featured 2 section.', 'minimum' ),
) );
genesis_register_sidebar( array(
'id' => 'home-featured-3',
'name' => __( 'Home Featured 3', 'minimum' ),
'description' => __( 'This is the home featured 3 section.', 'minimum' ),
) );
genesis_register_sidebar( array(
'id' => 'home-featured-4',
'name' => __( 'Home Featured 4', 'minimum' ),
'description' => __( 'This is the home featured 4 section.', 'minimum' ),
) );
//* Register widget area
genesis_register_sidebar( array(
'id' => 'featured',
'name' => __( 'Featured', 'minimum' ),
'description' => __( 'This is the featured section.', 'minimum' ),
) );
/***************
*
* Edited by Jeff
*
****************/
//* Add last updated date to the post info in entry header (requires HTML5 theme support)
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 . 'Last updated on: ' . the_modified_date('F j, Y', '', '', false);
}
return $post_info;
}
/***************
*
* End Edit
*
****************/
//* Add the featured section
add_action( 'genesis_after_header', 'sk_featured' );
function sk_featured() {
if ( is_active_sidebar( 'featured' ) ) {
printf( '', genesis_attr( 'featured' ) );
genesis_structural_wrap( 'featured' );
genesis_widget_area( 'featured' );
genesis_structural_wrap( 'featured', 'close' );
echo '';
}
}
Thanks for this. It works great using the Prose theme.
Hi I have added the code in functions.php. But nothing changes. I am using generate theme. But I don’t see modified dates in the post info area. It only shows published date.
Can you help please?
Hey man!
Found this post after searching around for sometime. Excellent and it worked like charm!
Here’s a question. What to do if I want to replace the current published date to the updated date (instead of showing it at the bottom)?
Cheers!
Hi,
Is there a function that can be used to sort the category/archive pages by the last modified date?
Best regards
https://gist.github.com/f67df4e2b8a158d285e6
Thanks
Just what i needed, works perfectly.