Add different Editor Styles for Custom Post Types in WordPress

Add different Editor Styles for Custom Post Types in WordPress

There is custom post type support added from wordpress 2.9 in wordpress. Many times we create the different types of post type in wordpress and show it i different way. We use the different styles for showing the content types..

Add different Editor Styles for Custom Post Types in WordPress

Add different Editor Styles for Custom Post Types in WordPress
Add different Editor Styles for Custom Post Types in WordPress

In wordpress we have the visual and html editor. For adding the different styles for custom post types just open your functions.php file put the following code in that file.


function my_editor_style() {
 global $current_screen;
 switch ($current_screen->post_type) {
 case 'post':
 add_editor_style('editor-style-post.css');
 break;
 case 'page':
 add_editor_style('editor-style-page.css');
 break;
 case 'product':
 add_editor_style('editor-style-product.css');
 break;
case 'shop':
 add_editor_style('editor-style-shop.css');
 break;

}
}
add_action( 'admin_head', 'my_editor_style' );

If you are not wordpress developer then dont use above code. In purabtech.in site you will find many wordpress tutorials and tips and hacks and plugins. Please write to me on support@purabtech.in

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.