Simple title solution for P2 theme
-
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.
@ma.tt or @noel – if you run across this, it would be cool if you added it to future releases. It’s simple and doesn’t change much.
In functions.php under the function – prologue_title_from_content on line 538
Find:
$title = str_replace("\n", " ", $title);
And replace it with:
// BEGIN first line title fix $first_line_title = explode( "\n" , $title ); $title = $first_line_title[0]; // 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.
The Fix:
It will set your post title and be reflected in the permalink.The Problem:
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.