Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Return the post type after the post title
<?php
/**
* [pbrocks_check_title_filter]
*
* @param [type] $title [description]
* @param [type] $post_id [description]
* @return [type] [description]
*/
function pbrocks_check_title_filter( $title, $post_id = null ) {
$current_post_type = get_post_type();
if ( in_the_loop() && ! is_front_page() ) {
$title = sprintf( '%1$s %2$s', $title, __( " $current_post_type ", 'pbrocks-the-title' ) );
return $title;
} else {
return $title;
}
}
add_filter( 'the_title', 'pbrocks_check_title_filter', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment