Background
What I am attempting to do is create a custom post layout template for a specific post (or even page) that the WordPress user can simply insert content using the WYSIWYG editor without having to worry about formatting (essentially "regions" they place content in). I want to have multiple of these "layout templates" so depending on the post (or page) they are editing in the WP admin area, they have a predefined area that they can place, for example, some text and an image.
What I've tried
add_filter( 'default_content', 'custom_editor_content' );
function custom_editor_content( $content ) {
global $post;
$id = $post->ID;
if ( $id == '32') {
$content = '
<div>place image here</div>
<p>place text here</p>
';
}
return $content;
}
Example initially taken from here
What I'm attempting
In the above example (which does not work), I want to essentially do a conditional statement saying if post id equals X, then use this template for the creation of the post
What I found out was the default_content
filter is only applied during the creation of a new post (or page) and therefore it has no effect on existing posts/pages, so conditionally running this code based on id
is useless.
End goals
There are a few outcomes I think may help me along...
If there is a way to run the
default_content
filter on post save/edit, then conditionally applying the filter based on post id would likely workFigure out a way to create multiple different custom post templates for an end-user. That is, have predefined regions that they can insert content within a post.
Or lastly, is there another way to allow a end-user, with no HTML ability, to just put content into a post or page and it will automatically get formatted for them (with my doing the formatting on the backend)?