{"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

Only Show Updated Date<\/h2>\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\n

Add Icon to Date<\/h2>\n\n\n\n
add_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\n

Remove Link from Date<\/h2>\n\n\n\n
add_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\n

As you can see, this filter is very powerful and gives you full control over your post dates.<\/p>\n","protected":false},"template":"","yoast_head":"\ngenerate_post_date_output - Documentation<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/docs.generatepress.com\/article\/generate_post_date_output\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"generate_post_date_output - Documentation\" \/>\n<meta property=\"og:description\" content=\"This filter returns the HTML that displays your post date along with your blog posts. You can use this filter to completely overwrite the HTML given, or even add to it. For example, if you wanted to add a clock icon before your date, you could do this: Only Show Updated Date By default, the […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/docs.generatepress.com\/article\/generate_post_date_output\/\" \/>\n<meta property=\"og:site_name\" content=\"Documentation\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GeneratePress\" \/>\n<meta property=\"article:modified_time\" content=\"2020-10-09T02:26:46+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@GeneratePress\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/docs.generatepress.com\/article\/generate_post_date_output\/\",\"url\":\"https:\/\/docs.generatepress.com\/article\/generate_post_date_output\/\",\"name\":\"generate_post_date_output - Documentation\",\"isPartOf\":{\"@id\":\"https:\/\/docs.generatepress.com\/#website\"},\"datePublished\":\"2017-03-15T23:04:18+00:00\",\"dateModified\":\"2020-10-09T02:26:46+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/docs.generatepress.com\/article\/generate_post_date_output\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/docs.generatepress.com\/article\/generate_post_date_output\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/docs.generatepress.com\/article\/generate_post_date_output\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/docs.generatepress.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Articles\",\"item\":\"https:\/\/docs.generatepress.com\/article\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"generate_post_date_output\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/docs.generatepress.com\/#website\",\"url\":\"https:\/\/docs.generatepress.com\/\",\"name\":\"Documentation\",\"description\":\"Get to Know GeneratePress\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/docs.generatepress.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"generate_post_date_output - Documentation","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/docs.generatepress.com\/article\/generate_post_date_output\/","og_locale":"en_US","og_type":"article","og_title":"generate_post_date_output - Documentation","og_description":"This filter returns the HTML that displays your post date along with your blog posts. You can use this filter to completely overwrite the HTML given, or even add to it. For example, if you wanted to add a clock icon before your date, you could do this: Only Show Updated Date By default, the […]","og_url":"https:\/\/docs.generatepress.com\/article\/generate_post_date_output\/","og_site_name":"Documentation","article_publisher":"https:\/\/www.facebook.com\/GeneratePress","article_modified_time":"2020-10-09T02:26:46+00:00","twitter_card":"summary_large_image","twitter_site":"@GeneratePress","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/docs.generatepress.com\/article\/generate_post_date_output\/","url":"https:\/\/docs.generatepress.com\/article\/generate_post_date_output\/","name":"generate_post_date_output - Documentation","isPartOf":{"@id":"https:\/\/docs.generatepress.com\/#website"},"datePublished":"2017-03-15T23:04:18+00:00","dateModified":"2020-10-09T02:26:46+00:00","breadcrumb":{"@id":"https:\/\/docs.generatepress.com\/article\/generate_post_date_output\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/docs.generatepress.com\/article\/generate_post_date_output\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/docs.generatepress.com\/article\/generate_post_date_output\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/docs.generatepress.com\/"},{"@type":"ListItem","position":2,"name":"Articles","item":"https:\/\/docs.generatepress.com\/article\/"},{"@type":"ListItem","position":3,"name":"generate_post_date_output"}]},{"@type":"WebSite","@id":"https:\/\/docs.generatepress.com\/#website","url":"https:\/\/docs.generatepress.com\/","name":"Documentation","description":"Get to Know GeneratePress","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/docs.generatepress.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/docs.generatepress.com\/wp-json\/wp\/v2\/keep-api\/387"}],"collection":[{"href":"https:\/\/docs.generatepress.com\/wp-json\/wp\/v2\/keep-api"}],"about":[{"href":"https:\/\/docs.generatepress.com\/wp-json\/wp\/v2\/types\/keep_articles"}],"wp:attachment":[{"href":"https:\/\/docs.generatepress.com\/wp-json\/wp\/v2\/media?parent=387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}