I'm creating a plugin that will allow users to create custom post types on the fly.

On the new post types, I want a custom Button to show In the TinyMCE.

Each of the post types has a unique description, so I want to add the buttons based on the post type description.

Something like:

 if ($post_type->description == 'Custom Description') { 

 // Add TinyMCE Button Here


To get the post type description, I found another post that suggested:


But it doesn't seem to be working correctly for me.

Any ideas how to add the TinyMCE buttons to a post type that has a certain post type description?


This is used in one of my plugins and working well, hopefully it can draw some inspiration:

public function efpd_run_tinymce(){
    global $typenow, $pagenow;

    if ( empty( $typenow ) && !empty( $_GET['post'] ) ) {
        $post = get_post( $_GET['post'] );
        $typenow = $post->post_type;

    $curpage = $pagenow . 'post-new.php?post_type=' . $typenow;

    if( 'fanpages' == $typenow || 'post-new.php?post-type=fanpages' == $curpage ) {

        if( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) )

        if( get_user_option( 'rich_editing' ) == 'true' ) {

            add_filter( 'mce_external_plugins', array( &$this, 'efpd_tinymce_plugins' ) );
            add_filter( 'mce_buttons_3', array( &$this, 'efpd_tinymce_buttons' ) );




I think potentially you could take $typenow and get the post type object and then use the description instead of the logic I've used in my example.

  • 1
    Thanks for the tips. I've never used $typenow for anything, so I did some research on it and while it doesn't help me, it lead me to an AWESOME article about custom post types. . .astronautdesigns.com/2011/12/… – Jason Bahl Jan 30 '12 at 5:00
  • So. . .after some more research. . .inspired by the article I found. . .because of your comment, I figured out my way of getting the description was flawed. Instead of get_post_type_object($post); I should have used $post_type = get_post_type_object(get_post_type($post)); All is working now, but the forum won't allow me to answer my own question yet. I'll post the answer when I'm allowed. Thanks for your input!! – Jason Bahl Jan 30 '12 at 5:07
  • Essentially that is the same as doing get_post_type_object( $typenow ) :) but I'm glad you figured it out! – Jared Jan 30 '12 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.