Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Modify the edit.php screen to show post excerpts if there is no title.
<?php
/*
Plugin Name: If No Title
Description: Modify the edit.php screen to show post excerpts if there is no title.
Version: 0.0.1
*/
add_action( 'load-edit.php', function()
{
add_filter( 'the_title', function( $title )
{
$post = get_post();
if( is_a( $post, '\WP_Post' ) && ! $post->post_title && $post->post_content )
$title = wp_trim_words( strip_shortcodes( strip_tags( $post->post_content ) ), 10 );
return $title;
} );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment