WordPress.org

Ready to get started?Download WordPress

Forums

Custom Editor based on Page Template (1 post)

  1. Greg McMullen
    Member
    Posted 1 year ago #

    Hey everyone, I'm trying to test something out based off of what I found on Smashing Magazine

    They have enlightened me on a way to create multi-column layouts within the editor based on content types (post/page/custom). What I am trying to do is create a way for the columns to load in when the TEMPLATE (2-col/3-col) is selected.

    I do NOT care about keeping content within the editor at this point, but it would obviously be a plus. This is what I have, and it works aside from being able to change the content on save with a template ("test.php") being selected.

    Any help would be appreciated:

    add_filter( 'default_content', 'custom_editor_content');
    // Testing the stuff for custom post type changing shit around
    
         function custom_editor_content($content){
              global $current_screen;
              // This is where the conditional check for new templates will go
              if ( $current_screen->post_type == 'page'){
                   $content = 'This is the test page type';
              } elseif ($current_screen->post_type == 'post' ){
                   $content = 'This is a post';
              }
              else {
                   $content = '
                   <div class="content-col-main">This is your main page content </div>
                   <div class="content-col-side">This is your sidebar content </div>';
              }
         return $content;
         }
    add_editor_style( 'editor-styles.css' );

    I also tried looking at this, but it was only useful for adding custom meta boxes on template change (save), instead of adjusting the editor content.

Topic Closed

This topic has been closed to new replies.

About this Topic