Defining the writing area of the dashboard editor

the first of my upcoming ‘tips and tricks’ – a handy function to style the editor area of your self-hosted wordpress blog or cms:
if you are working on a modern widescreen monitor, but want to restrict the wordpress editor area (your writing paper, so to speak) to the width as it will later show in your blog, here is a tip what to add to functions.php of your theme:

function custom_max_width_editor() {
echo '<style type="text/css"> textarea#content, #content_ifr {
border-right: 1px solid #ddd; }</style>';
add_action('admin_head', 'custom_max_width_editor');

the ‘min-height’ is optional, and will give you a larger writing area to start with.
and the border shows clearly how wide the defined writing area is.
adjust the number values, and enjoy the next level of control over your wordpress.

you might even want to add the predominant background-color of your blog’s content area …

a big thank you to @Purren from the wordpress support forum, who submitted a correction to make it also work for the visual editor.

wp3 has brought the ‘add_editor_style()‘ function which makes the above tip redundant.

for theme independant, more permament changes, the principle can also be turned into a basic plugin; in this example to change the font-size in the html editor:

Plugin Name: Html Editor Font Size
Description: set the font size for the html editor.
License: GPL2
function custom_font_size_html_editor() {
echo '<style type="text/css"> #editorcontainer textarea#content {
font-size: 20px; }</style>';
add_action('admin_head', 'custom_font_size_html_editor');

Highlight the post’s categories in the category list

highlighting the categories of a post in single post view is a useful trick to allow the viewer to find related posts.

there are plugins available which extend the functionality of the standard category widget to do this.

sometimes, however, it can be desirable to have the same feature with a function that you can use like you would use ‘wp_list_categories();’ – exactly with the same arguments.

/* hi_list_categories() to highlight the current categories of a post in single.php;
uses the arguments in the same way as wp_list_categories();
alchymyth 2010 / */
function hi_list_categories($args) {
//following section is extracted from
$defaults = array(
'show_option_all' => '',
'orderby' => 'name',
'order' => 'ASC',
'show_last_update' => 0,
'style' => 'list',
'show_count' => 0,
'hide_empty' => 1,
'use_desc_for_title' => 1,
'child_of' => 0,
'feed' => '',
'feed_type' => '',
'feed_image' => '',
'exclude' => '',
'exclude_tree' => '',
'current_category' => 0,
'hierarchical' => true,
'title_li' => __( 'Categories' ),
'echo' => 1,
'depth' => 0
$r = wp_parse_args( $args, $defaults );
if ( !isset( $r['pad_counts'] ) && $r['show_count'] && $r['hierarchical'] ) {
$r['pad_counts'] = true;
if ( isset( $r['show_date'] ) ) {
$r['include_last_update_time'] = $r['show_date'];
if ( isset( $r['echo'] ) ) {
$echo_or_return = $r['echo'];
} ; $r['echo'] = 0;
if ( true == $r['hierarchical'] ) {
$r['exclude_tree'] = $r['exclude'];
$r['exclude'] = '';
extract( $r );
//end of extracted code
global $post;
// highlighting only for single post view
if(is_single()) :
$categories = wp_get_post_categories($post->ID);
foreach ($categories as $catid) {
$cat = get_category($catid);
$cats[] = $cat->cat_ID;
$cats_list = wp_list_categories( $r );
foreach($cats as $value) {
if(preg_match('#-item-' . $value . '">#', $cats_list)) {
$cats_list = str_replace('item-' . $value . '">', 'item-' . $value . ' current-cat">', $cats_list);
if($echo_or_return == 1) { echo $cats_list; }
else { return $cats_list; } ;
else :
//use default category list if not single post view
wp_list_categories( $args );
} //end of function hi_list_categories();

in the same way, as you would have used ‘wp_list_categories();’ you can now use ‘hi_list_categories();’ which will add the class ‘.current-cat’ to each of the categories of the post in single post view.