Stop Censorship Stop Censorship Ribbon Comments on: How to use custom styles in the WordPress post editor http://www.wdmac.com/how-to-use-custom-styles-in-the-word-press-post-editor Blogging about everything from WordPress Templates to Food Recipes. Tue, 17 Jan 2012 15:25:55 +0000 hourly 1 http://wordpress.org/?v=3.3.1 By: WDMAC http://www.wdmac.com/how-to-use-custom-styles-in-the-word-press-post-editor/comment-page-1#comment-189 WDMAC Thu, 03 Nov 2011 16:46:43 +0000 http://www.wdmac.com/?p=771#comment-189 Hi Brian Your are absolutely right in principle. However in this particular case I need the styles to be loaded to the front-end, and not just in the admin area. The all point is letting people use and apply custom styles trough the WYSIWYG editor so they can be “interpreted” in the front-end to the general public. If my styles or scripts were only to be used in the admin area, then, admin_init (or eventually admin_head) were indeed the correct hooks to use. Thanks! MAC :) Hi Brian

Your are absolutely right in principle. However in this particular case I need the styles to be loaded to the front-end, and not just in the admin area.

The all point is letting people use and apply custom styles trough the WYSIWYG editor so they can be “interpreted” in the front-end to the general public.
If my styles or scripts were only to be used in the admin area, then, admin_init (or eventually admin_head) were indeed the correct hooks to use.

Thanks!

MAC :)

]]>
By: WDMAC http://www.wdmac.com/how-to-use-custom-styles-in-the-word-press-post-editor/comment-page-1#comment-188 WDMAC Thu, 03 Nov 2011 16:31:14 +0000 http://www.wdmac.com/?p=771#comment-188 Hi Bones Thanks for your warnings. I've updated the code to your suggestions, except for point 1, where I haven't had the time, yet, to check. Thanks! MAC :) Hi Bones

Thanks for your warnings.
I’ve updated the code to your suggestions, except for point 1, where I haven’t had the time, yet, to check.

Thanks!

MAC :)

]]>
By: Bones http://www.wdmac.com/how-to-use-custom-styles-in-the-word-press-post-editor/comment-page-1#comment-187 Bones Thu, 03 Nov 2011 11:48:39 +0000 http://www.wdmac.com/?p=771#comment-187 Hello. Nice guide, still i think there are some proablems. 1. the line below is useless, and should be deleted. add_filter( ‘mce_css’, ‘tdav_css’ ); 2. the following line: wp_enqueue_style( ‘myCustomStyles’, get_bloginfo(‘template_url’).’/mycustomstyles.css’, ”,”’,'all’ ); would work better if changed in: wp_enqueue_style( ‘myCustomStyles’, get_bloginfo(‘stylesheet_directory’).’/mycustomstyles.css’, ”,”’,'all’ ); 3. the following line should be added. it helps make the editor look like the custom css. add_editor_style('mycustomstyles.css'); Your guide plus my changes worked graite for me. I hope it will help others. Thx for the guide. Hello.

Nice guide, still i think there are some proablems.

1. the line below is useless, and should be deleted.
add_filter( ‘mce_css’, ‘tdav_css’ );

2. the following line:
wp_enqueue_style( ‘myCustomStyles’, get_bloginfo(‘template_url’).’/mycustomstyles.css’, ”,”’,’all’ );

would work better if changed in:
wp_enqueue_style( ‘myCustomStyles’, get_bloginfo(‘stylesheet_directory’).’/mycustomstyles.css’, ”,”’,’all’ );

3. the following line should be added. it helps make the editor look like the custom css.
add_editor_style(‘mycustomstyles.css’);

Your guide plus my changes worked graite for me. I hope it will help others.
Thx for the guide.

]]>
By: Shane http://www.wdmac.com/how-to-use-custom-styles-in-the-word-press-post-editor/comment-page-1#comment-178 Shane Thu, 20 Oct 2011 14:19:32 +0000 http://www.wdmac.com/?p=771#comment-178 When I add the code to my functions.php file it causes the text in the editor to go white so I can see it and disables the visual editor altogether. I am using version 3.2.1 Any idea what I can do to get this working? Thanks! When I add the code to my functions.php file it causes the text in the editor to go white so I can see it and disables the visual editor altogether. I am using version 3.2.1
Any idea what I can do to get this working?
Thanks!

]]>
By: Ian Hackett http://www.wdmac.com/how-to-use-custom-styles-in-the-word-press-post-editor/comment-page-1#comment-168 Ian Hackett Tue, 27 Sep 2011 12:48:20 +0000 http://www.wdmac.com/?p=771#comment-168 I seem to be having a problem with this. After adding the code to my functions.php file, i get this at the bottom of my editor pages. Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'tdav_css' not found or invalid function name in C:\xampp\xampplite\htdocs\websites\wordpress\wp-includes\plugin.php on line 170. Also, all the TinyMCE buttons have disappeared, and the page layout has gone a bit funny and out of place. What's gone wrong? I seem to be having a problem with this.
After adding the code to my functions.php file, i get this at the bottom of my editor pages.
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘tdav_css’ not found or invalid function name in C:\xampp\xampplite\htdocs\websites\wordpress\wp-includes\plugin.php on line 170.
Also, all the TinyMCE buttons have disappeared, and the page layout has gone a bit funny and out of place.
What’s gone wrong?

]]>
By: Brian K. Johnson http://www.wdmac.com/how-to-use-custom-styles-in-the-word-press-post-editor/comment-page-1#comment-142 Brian K. Johnson Sat, 06 Aug 2011 00:26:30 +0000 http://www.wdmac.com/?p=771#comment-142 Remove my comment if I am wrong, but I think that it would be better to use admin_init rather than init for things that you want to happen only in the Admin area. Then WP isn't bothering to load extra code when just displaying a regular page for non-admin. add_action('admin_init', 'mycustomStyles'); Remove my comment if I am wrong, but I think that it would be better to use
admin_init
rather than
init
for things that you want to happen only in the Admin area.
Then WP isn’t bothering to load extra code when just displaying a regular page for non-admin.
add_action(‘admin_init’, ‘mycustomStyles’);

]]>
By: Davide http://www.wdmac.com/how-to-use-custom-styles-in-the-word-press-post-editor/comment-page-1#comment-132 Davide Fri, 27 May 2011 00:43:32 +0000 http://www.wdmac.com/?p=771#comment-132 No way to paste it, in any case it was a link rel with type and href with an absolute path to the css starting from wp-content... No way to paste it, in any case it was a link rel with type and href with an absolute path to the css starting from wp-content…

]]>
By: Davide http://www.wdmac.com/how-to-use-custom-styles-in-the-word-press-post-editor/comment-page-1#comment-131 Davide Fri, 27 May 2011 00:41:04 +0000 http://www.wdmac.com/?p=771#comment-131 I can't paste the header.php modification therefore I comment it: /**/ I can’t paste the header.php modification therefore I comment it:

/**/

]]>
By: Davide http://www.wdmac.com/how-to-use-custom-styles-in-the-word-press-post-editor/comment-page-1#comment-130 Davide Fri, 27 May 2011 00:39:19 +0000 http://www.wdmac.com/?p=771#comment-130 "" “”

]]>
By: Davide http://www.wdmac.com/how-to-use-custom-styles-in-the-word-press-post-editor/comment-page-1#comment-129 Davide Fri, 27 May 2011 00:38:44 +0000 http://www.wdmac.com/?p=771#comment-129