Disable WYSIWYG Editor For Custom Post Types

If you need to make sure that your custom post type doesn’t have the ‘visual’ tab, you can easily diable it. Suppose you have a custom post type named ‘movie’:

add_filter( 'user_can_richedit', 'disable_for_cpt' );
function disable_for_cpt( $default ) {
	global $post;
	if ( 'movie' == get_post_type( $post ) )
		return false;
	return $default;

Add Font-Select Drop Down to Visual Editor

Add the font-select menu to the 2nd row of buttons (revealed with the Kitchen Sink button)

If some items aren’t removed from the second row, the buttons won’t fit nicely on a 1024×768 screen.

See WordPress’s default buttons in wp_tiny_mce()

add_filter('mce_buttons_2', 'add_fontselect_row_2' );

function add_fontselect_row_2( $mce_buttons ) {
        find the keys of the buttons to be sacrificed
    $pastetext = array_search( 'pastetext', $mce_buttons );
    $pasteword = array_search( 'pasteword', $mce_buttons );
    $removeformat = array_search( 'removeformat', $mce_buttons );

    unset( $mce_buttons[ $pastetext ] );
    unset( $mce_buttons[ $pasteword ] );
    unset( $mce_buttons[ $removeformat ] );

        insert the new dropdown where the sacrificed buttons used to be
        alter as needed
    array_splice( $mce_buttons, $pastetext, 0, 'fontselect' );
    return $mce_buttons;

But if you’re adding the 3rd row, you’re probably clear (unless you have other plugins that are adding buttons).

add_filter('mce_buttons_3', 'add_fontselect_row_3' );

function add_fontselect_row_3( $mce_buttons ) {
    $mce_buttons[] = 'fontselect';
    return $mce_buttons;

Currently, any buttons added to the 3rd or 4th rows will always be visible (Kitchen Sink only shows/hides the 2nd row) – but a patch has been submitted to correct this, hopefully it’ll be committed.

However, if you’ll probably want to clean up the font options – remove fonts that you’ll never use (or should never be used).

add_filter('tiny_mce_before_init', 'restrict_font_choices' );
function restrict_font_choices( $initArray ) {
    $initArray['theme_advanced_fonts'] = 
        'Andale Mono=andale mono,times;'.
        //'Arial Black=arial black,avant garde;'.
        'Book Antiqua=book antiqua,palatino;'.
        //'Comic Sans MS=comic sans ms,sans-serif;'.
        'Courier New=courier new,courier;'.
        'Times New Roman=times new roman,times;'.
        'Trebuchet MS=trebuchet ms,geneva;'.
        //'Wingdings=wingdings,zapf dingbats'.
    return $initArray;

Removed Categories Dropdown Filter

On the All Posts page, there are a series of filters for narrowing down what posts are displayed.

To remove the categories filter, use this:

add_action( 'load-edit.php', 'no_category_dropdown' );
function no_category_dropdown() {
	add_filter( 'wp_dropdown_cats', '__return_false' );

In the action hook, change ‘edit.php’ if you want to remove the dropdown on other pages.

Remove Bulk Actions Dropdown

To remove the bulk actions dropdown menu, you simply need to remove all actions! Just hook in and replace the default actions array with an empty array.

add_filter( 'bulk_actions-' . 'edit-post', '__return_empty_array' );

In this case, only the bulk actions menu on the All Posts page will be removed. To use elsewhere, replace ‘edit-post’ with the screen ID.

Disable the Auto-Scroll/Internal Anchors in Read More Links

If you don’t like that the ‘read more’ links automatically scroll you down the page (to the beginning of what ever comes after the <–more--> tag), you can so a little pattern matching to remove the internal anchor.

add_filter( 'the_content_more_link', 'read_more_no_jump', 10, 2 );
function read_more_no_jump( $link, $text ) {
	$no_more = preg_replace( '/#more-([0-9]*)/', '', $link );
	return $no_more;

Force Default Editor Mode

Normally, WordPress will remember which editor mode you were in (Visual or HTML). So if you were using the HTML editor and you save a page, you’ll be returned to the HTML editor.

If you (or your clients) would benefit from always returning to particular mode, you can set that up

add_filter( 'wp_default_editor', 'force_default_editor' );
function force_default_editor() { 
	//allowed: tinymce, html, test
	return 'tinymce';

*Functionality is there but quirky in pre-3.3

Change Protected Posts Prefix

If you’ve marked a post as “Protected” it is automatically prefixed with “Protected: ”

You may not like that. Here’s how you can change it:

add_filter('protected_title_format', 'change_protected_title_format');
function change_protected_title_format() {
	return 'Members Only: %s';

*If this seems oddly familiar, check out yesterday’s post.