Filter WordPress Title but Only in Admin Area

A drawing of a small terrier dog jumping through a hoop held by a monkey.

I am playing around with unfurling1 open graph data in the WordPress TinyMCE editor. You can see what that looks like in the video above. It’s a lot like the oEmbed experience in WordPress but with the open graph information driving it.

I want the data to go into the post body but I don’t want a title that links to a post because these types of posts are more about getting people out to that original content. People could still manually enter a title and that’d work but if they choose not to I thought it’d be nice if it was just removed from the equation.

That’s pretty nice on the front end but on the backend you end up with a maze of posts with the title (no title). That seemed irritating so I cobbled together the following function which creates a mini excerpt from the post content but only applies the filter when you’re in the backend/dashboard. Nothing fancy but a nice little pattern that I expect I’ll use again.

add_filter('the_title', 'new_short_admin_title', 10, 2);
function new_short_admin_title($title, $id) {
	if ( is_admin() ) {
	    if ($title === null || $title == '' || $title == '(no title)'){
	    	$title = super_short_excerpt();
    return $title;

function super_short_excerpt() {
    return wp_trim_words(get_the_excerpt(), 5);


1 I like how furl and url have similar sounds but it is a ridiculous term.

2 thoughts on “Filter WordPress Title but Only in Admin Area

    1. I’m considering building a WordPress plugin that uses opengraph and oembed to build fairly rich bookmarks. Maybe the name should be Unfurl.

Comments are closed.