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?
1 Answer
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:
-
I type too slowly, apparently. Exactly the answer I was going to give.– Pat JApr 29, 2013 at 20:40
-
-
-
-
@IlyaKnaup Please, no. :) Make a plugin for that, something like this one.– fuxia ♦Apr 30, 2013 at 8:23