Keep the simplistic beauty of P2 while adding the option for customized titles by using the first line as the title. If there’s no first line break, title it as usual.
In functions.php under the function – prologue_title_from_content on line 538
$title = str_replace("\n", " ", $title);
And replace it with:
// BEGIN first line title fix $first_line_title = explode( "\n" , $title ); $title = $first_line_title; // END first line title fix //$title = str_replace("\n", " ", $title);
I commented out the original line but left it there just in case I changed my mind and wanted to go back (since I’m kind of a php newb). When you upgrade P2 to the next version, that line will be wiped out so keep that in mind.
It will set your post title and be reflected in the permalink.
It doesn’t show up as a H2 title in the “feed” for some reason.
I’m guessing there’s a special hook or something on the actual edit post page that triggers the title being set in WP (that’s more than I was interested in getting into).
Taking it a little farther:
It should be pretty easy to add a checkbox to the P2 options page to give users the option to “Use first line as title”.
- The topic ‘Simple title solution for P2 theme’ is closed to new replies.