generate_post_date_output

generate_post_date_output

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 HTML for the published date and updated date (if it exists) is added to your site. The updated date is hidden with CSS.

In some cases, you might only want the updated date HTML to display. Then this filter can be used:

add_filter( 'generate_post_date_show_updated_only', '__return_true' );

Add Icon to Date

add_filter( 'generate_post_date_output','tu_add_to_post_date' );
function tu_add_to_post_date( $output ) {
return ' ' . $output;
}

Remove Link from Date

add_filter( 'generate_post_date_output', function( $output, $time_string ) {
printf( '%s ',
$time_string
);
}, 10, 2 );

As you can see, this filter is very powerful and gives you full control over your post dates.

generate_comments_title_output

generate_comments_title_output

The generate_comments_title_output filter allows you to change the output of the comment title element.

For example, if we want to change the comment title from

 to

, then we can we this PHP snippet:

add_filter( 'generate_comments_title_output', function( $output, $comments_title ) {
return sprintf(
'

%s

',
esc_html( $comments_title )
);
}, 10, 2 );

generate_after_do_template_part

generate_after_do_template_part

The generate_after_do_template_part hook appears at the end of generate_do_template_part() function.

This function is responsible for displaying the content on your page. In archives, it displays each post.

We can use this hook to display something after each post, or after a specific post. For example, this function will output text after the 4th post in your archives:

add_action( 'generate_after_do_template_part', function() {
global $wp_query;

if ( 3 === $wp_query->current_post ) {
echo 'Look at me after the fourth post';
}
} );

generate_page_class

generate_page_class

The generate_page_class filter allows you to add custom classes to the #page element.

For example:

add_filter( 'generate_page_class', function( $classes ) {
$classes[] = 'my-custom-class';

return $classes;
} );