Wordpress pre-populate main content with content, restrict to post type


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /* -------- put default content into custom post type's main content box -------------- */
  2.  
  3. function my_preset_content() {
  4.  
  5. global $post;
  6.  
  7. if ( $post->post_content == '' and $post->post_type == 'custom_post_type' ) {
  8.  
  9. $default_content = 'my preset content here';
  10.  
  11. } else {
  12. $default_content = $post->post_content;
  13. }
  14. return $default_content;
  15. }
  16.  
  17. add_filter('the_editor_content', 'my_preset_content');

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.