Archive for May 14th, 2008

WordPress 2.5/2.5.1 Post Write Panel Hack - Categories Box

Hi Everyone,

— read the updates below —

If you’re using WordPress 2.5.1, and you don’t like the Categories box being underneath the post write box, and you want the box back in the sidebar, this is for you!

Screenshot:

—-

Before you start, backup your wp-admin/edit-form-advanced.php file.

After backing it up, locate the file and open it in your code/text editor and follow these steps:

Step 1) Find and delete this:

<div id="categorydiv" class="postbox <?php echo postbox_classes('categorydiv', 'post'); ?>">
<h3><?php _e('Categories') ?></h3>
<div class="inside">
 
<div id="category-adder" class="wp-hidden-children">
	<h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
	<p id="category-add" class="wp-hidden-child">
		<input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" />
		<?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
		<input type="button" id="category-add-sumbit" class="add:categorychecklist:categorydiv button" value="<?php _e( 'Add' ); ?>" tabindex="3" />
		<?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
		<span id="category-ajax-response"></span>
	</p>
</div>
 
<ul id="category-tabs">
	<li class="ui-tabs-selected"><a href="#categories-all" tabindex="3"><?php _e( 'All Categories' ); ?></a></li>
	<li class="wp-no-js-hidden"><a href="#categories-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
</ul>
 
<div id="categories-all" class="ui-tabs-panel">
	<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
		<?php dropdown_categories(); ?>
	</ul>
</div>
 
<div id="categories-pop" class="ui-tabs-panel" style="display: none;">
	<ul id="categorychecklist-pop" class="categorychecklist form-no-clear" >
		<?php wp_popular_terms_checklist('category'); ?>
	</ul>
</div>
 
</div>
</div>


Step 2) Find and delete this:

<div class="side-info">
<h5><?php _e('Related') ?></h5>
 
<ul>
<?php if ($post_ID): ?>
<li><a href="edit.php?p=<?php echo $post_ID ?>"><?php _e('See Comments on this Post') ?></a></li>
<?php endif; ?>
<li><a href="edit-comments.php"><?php _e('Manage All Comments') ?></a></li>
<li><a href="edit.php"><?php _e('Manage All Posts') ?></a></li>
<li><a href="categories.php"><?php _e('Manage All Categories') ?></a></li>
<li><a href="edit-tags.php"><?php _e('Manage All Tags') ?></a></li>
<li><a href="edit.php?post_status=draft"><?php _e('View Drafts'); ?></a></li>
<?php do_action('post_relatedlinks_list'); ?>
</ul>
</div>

Step 3) Find this (Don’t delete it - just find it):

<span id="autosave"></span>
</p>

Step 4) Paste this underneath:

<div class="side-info" style="margin-left: -15px;  ">
 
<div id="categorydiv" class="postbox <?php echo postbox_classes('categorydiv', 'post'); ?>" style="width: 260px;">
<h3>Categories</h3>
<div class="inside">
 
<div id="category-adder" class="wp-hidden-children" style="margin-left: -5px; ">
<h4>	<a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a></h4>
	<p id="category-add" class="wp-hidden-child" style="width: 250px; " >
		<input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php _e( 'New category name' ); ?>" tabindex="3" style="width: 150px; " /><br />
		<?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
		<input type="button" id="category-add-sumbit" class="add:categorychecklist:categorydiv button" value="<?php _e( 'Add' ); ?>" tabindex="3"  />
		<?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
		<span id="category-ajax-response"></span>
	</p>
</div>
 
<ul id="category-tabs" style="width: 2px; ">
 
</ul>
 
<div id="categories-all" class="ui-tabs-panel"  style="height: 400px; margin: 2px; ">
	<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
		<?php dropdown_categories(); ?>
	</ul>
</div>
 
 
 
</div>
</div>
</div>

Step 5) Save (make sure your old copy was backed up).

Step 6) Login to your WP Admin and go to “Write > Post” and check it out. If you like it let me know that it worked. If not, I cannot provide support but you can still contact me at info [at] kulpreetsingh [dot] com.

Disclaimer:
This has been tested on WP 2.5.1. I am not responsible for your WP installation or for this fix. Please backup your edit-form-advanced.php file and restore it if this doesn’t work.

—-

Update:

Screencast by Rebecca Bollwitt (Miss604) on how to do the above:

—-

Update 2:

It turns out there’s a plugin that does this as well! Probably easier to manage for the non-coding population, especially because it will / should extend regardless of your version updates. It is a little different from my method, but the concept is the same. The website’s in Turkish but the plugin page is in English: http://beyn.org/sidecat/

—-

Update 3:

Peter Keung took this fix and the plugin above and made a new plugin. Thank you Peter! You can download it here: http://www.theblog.ca/wp-content/uploads/2008/05/sidecat_reloaded.txt