{"id":387,"date":"2017-03-15T23:04:18","date_gmt":"2017-03-15T23:04:18","guid":{"rendered":"https:\/\/docs.generatepress.com\/?post_type=keep_articles&p=387"},"modified":"2020-10-09T02:26:46","modified_gmt":"2020-10-09T02:26:46","slug":"generate_post_date_output","status":"publish","type":"keep_articles","link":"https:\/\/docs.generatepress.com\/article\/generate_post_date_output\/","title":{"rendered":"generate_post_date_output"},"content":{"rendered":"\n
This filter returns the HTML that displays your post date along with your blog posts.<\/p>\n\n\n\n
You can use this filter to completely overwrite the HTML given, or even add to it.<\/p>\n\n\n\n
For example, if you wanted to add a clock icon before your date, you could do this:<\/p>\n\n\n\n
By default, the HTML for the published date and updated date (if it exists) is added to your site. The updated date is hidden with CSS.<\/p>\n\n\n\n
In some cases, you might only want the updated date HTML to display. Then this filter can be used:<\/p>\n\n\n\n
add_filter( 'generate_post_date_show_updated_only', '__return_true' );<\/code><\/pre>\n\n\n\nAdd Icon to Date<\/h2>\n\n\n\nadd_filter( 'generate_post_date_output','tu_add_to_post_date' );\nfunction tu_add_to_post_date( $output ) {\n return '<i class=\"fa fa-clock-o\" aria-hidden=\"true\"><\/i> ' . $output;\n}<\/code><\/pre>\n\n\n\nRemove Link from Date<\/h2>\n\n\n\nadd_filter( 'generate_post_date_output', function( $output, $time_string ) {\n\tprintf( '<span class=\"posted-on\">%s<\/span> ',\n\t\t$time_string\n\t);\n}, 10, 2 );<\/code><\/pre>\n\n\n\nAs you can see, this filter is very powerful and gives you full control over your post dates.<\/p>\n","protected":false},"template":"","yoast_head":"\n
generate_post_date_output - Documentation<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n