Skip to content

Instantly share code, notes, and snippets.

@octalmage
Created February 28, 2017 15:33
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 octalmage/e0eb75ae9c1336b4a2bea9f6690337d7 to your computer and use it in GitHub Desktop.
Save octalmage/e0eb75ae9c1336b4a2bea9f6690337d7 to your computer and use it in GitHub Desktop.
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