Created
March 15, 2021 14:19
-
-
Save pbrocks/587e990d54a44eaacc54920c9ae7e20e to your computer and use it in GitHub Desktop.
Return the post type after the post title
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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