Um im WordPress Backend einen eigenen Editor einzubauen, gibt es eine wunderbare Funktion „wp_editor()“.
Um diesen nun zu nutzen, kann in der functions.php dieser Code eingebaut werden:
function your_function_callback($post) { global $wpdb; wp_nonce_field( 'marginal', 'yourname_nonce' ); $value = get_post_meta( $post->ID, '_yourname', false ); wp_editor($value[0],'_yourname'); } function add_editor() { add_meta_box( 'yourname', __('Deine Überschrift'), 'your_function_callback', 'page', 'normal', 'high' ); add_meta_box( 'marginal', __('Deine Überschrift'), 'your_function_callback', 'post', 'normal', 'high' ); } add_action( 'add_meta_boxes', 'add_editor', 5 ); function save_your_function($post_id) { if(!isset($_POST['yourname_nonce'])){ return; } if(!wp_verify_nonce($_POST['yourname_nonce'],'yourname')){ return; } if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){ return; } if(!current_user_can('edit_post',$post_id)){ return; } if(!isset($_POST['_yourname'])){ return; } update_post_meta( $post_id,'_marginal',$_POST['_yourname']); } add_action('save_post','save_your_function');
Um diesen Code dann irgendwo im Template (Frontend) ausgeben zu lassen:
echo apply_filters('the_content',get_post_meta(get_the_id(),'_yourname',true));
Somit ist eine ganz einfach Möglichkeit geschaffen, individuellen Content zu schaffen, beispielsweise für eine Marginalspalte.