Skip to content

Instantly share code, notes, and snippets.

@pbrocks
Created March 15, 2021 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbrocks/587e990d54a44eaacc54920c9ae7e20e to your computer and use it in GitHub Desktop.
Save pbrocks/587e990d54a44eaacc54920c9ae7e20e to your computer and use it in GitHub Desktop.
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