I’ve built a simple sales page theme and would like to enhance it a bit by allowing the input of default content (including headers, bullet points, testimonial blockquotes and the ubiquitous “add to cart” button).
What are the options for adding html snippets to content pages and/or posts?
Ideally, when I click “Add New” from the Post or Page menu, the content would already be pre-populated with the sales page default content.
Or perhaps even better, I could add a menu below the “Add New” link like “Add New Salespage” and by clicking that, it would default the sales page content.
I’d like to have a page in my theme folder called salespage.html (or salespage.txt, or salespage.php, whichever is easier to work with) and this would be the content that is used to prepopulate the editor.
Any help much appreciated.
UPDATE: Thanks to Chris_O’s answer below, I was able to find the solution. I’ve augmented Chris suggested solution to load the content from an external file….
if (get_option("cb2_theme") == "salespage")
{
//added to support salespage creation
add_filter( 'default_content', 'my_editor_content' );
function my_editor_content( $content ) {
if(file_exists(ABSPATH.'wp-content/themes/clickbump_wp3/styles/salespage/default-content.html')){$content = file_get_contents(ABSPATH.'wp-content/themes/mytheme/styles/salespage/default-content.html');}else{$content = "Enter your salespage content here. h1-h3 tags, blockquotes etc";}
//$content = "This is some custom content I'm adding to the post editor because I hate re-typing it.";
return $content;
}
}
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
@Scott B,
I just read a post on Justin Tadlocks Blog regarding this same issue.
The Solution
Use the default_content filter hook and it to the themes function.php file.
Example:
<?php
add_filter( 'default_content', 'my_editor_content' );
function my_editor_content( $content ) {
$content = "This is some custom content I'm adding to the post editor because I hate re-typing it.";
return $content;
}
?>
You could add XHTML or anything you wanted to the $content string
When you click “Add New Post” you get:

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0