Add post_id to post_title only to posts with a post_type of “post”

Share
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
add_filter('the_title', 'add_id_to_title', 10, 2);
function add_id_to_title($title, $post_id) {
//use the id to check the post type and only add the id if it has a type of "post"
if(get_post_type($post_id) == "post")
$title = $post_id.': '.$title;
return $title;
}
add_filter('the_title', 'add_id_to_title', 10, 2); function add_id_to_title($title, $post_id) { //use the id to check the post type and only add the id if it has a type of "post" if(get_post_type($post_id) == "post") $title = $post_id.': '.$title; return $title; }
add_filter('the_title', 'add_id_to_title', 10, 2);
function add_id_to_title($title, $post_id) {
    //use the id to check the post type and only add the id if it has a type of "post"
    if(get_post_type($post_id) == "post")
        $title = $post_id.': '.$title;
    return $title;
}