Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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;
}
}
share|improve this question
    
@Scott B: @Chris_O has a good answer but I'm curious so would like to explore: do you envision as salespage.html because that's what you need to that was what occurred to you? Would having a page in the admin where you could actually edit and save the default sales page be preferable? Also, do you only need one or do you maybe need many? BTW, these questions would actually augment @Chris_O's answer, not be an alternate too. –  MikeSchinkel Sep 7 '10 at 1:13
    
@Mike, not sure I understand the first part of your question, could you take a look at it? I don't see a need for too many, each person will have their own unique content, so I'm just trying to give them the basics (headings, intro, bullet points, closing, guarantee, cart button, disclaimer, etc) –  Scott B Sep 7 '10 at 11:52
    
@Scott B I mean why did you support a file on disk rather than an place in the admin? For multiple, have you considering created a "Sales Letter" custom post type? –  MikeSchinkel Sep 7 '10 at 23:53
    
I had not thought of that, but I thinks its an excellent suggestion so I created another question with that in mind. –  Scott B Sep 8 '10 at 19:51

1 Answer 1

up vote 3 down vote accepted

@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: alt text

share|improve this answer
    
Thanks, that will work fine. I'll wrap the bits in functions.php so that it only inserts content when the salespage template is active (my theme has multiple templates, only 1 would be appropriate for default content). –  Scott B Sep 7 '10 at 11:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.