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 was wondering, is it possible to set default text to appear inside "text" part of the wysiwyg located on Create post page? So every time you click add new post that text would be there waiting for you?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

There is a filter named default_content. It does exactly what the name says. :)

Example:

add_filter( 'default_content', 't5_preset_editor_content', 10, 2 );

/**
 * Fills the default content for post type 'post' if it is not empty.
 *
 * @param string $content
 * @param object $post
 * @return string
 */
function t5_preset_editor_content( $content, $post )
{
    if ( '' !== $content or 'post' !== $post->post_type )
    {
        return $content;
    }

    return 'This is the <em>default</em> content. You may customize it.';
}

As you can see, the post type is already available, so you could set different defaults for different post types.

Related filters are default_title and default_excerpt. They work the same way.

You can also send someone a link with parameters for content, post_title and excerpt:

http://example.com/wp-admin/post-new.php?content=hello+world%21&post_title=Sample+Title&excerpt=custom+excerpt

Output:

enter image description here

share|improve this answer
    
I type too slowly, apparently. Exactly the answer I was going to give. –  Pat J Apr 29 '13 at 20:40
    
@PatJ I didn’t type that much. –  toscho Apr 29 '13 at 20:41
    
toscho has beaten me before too @PatJ :) –  Andrew Bartel Apr 29 '13 at 21:43
    
@toscho goes into functions.php correct? –  Ilya Knaup Apr 29 '13 at 23:47
    
@IlyaKnaup Please, no. :) Make a plugin for that, something like this one. –  toscho Apr 30 '13 at 8:23
show 1 more comment

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.