Template plugin for blog posts? [closed]

You could create a custom post type post_templates. It should not be publicly queryable, and the admin only should be able to create or edit items.

In your post editor you could then add a TinyMCE button/dropdown to let the editor select a template. Here is a very basic example plugin illustrating how to work with preselected post content:

/*
 * See wp-admin/includes/post.php function get_default_post_to_edit()
 * There are also the filters 'default_title' and 'default_excerpt'
 */
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.';
}

Leave a Comment