Change textarea_rows on all WYSIWYG fields for a specific post type

Support MB Builder Change textarea_rows on all WYSIWYG fields for a specific post type

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #40605
    Kyle IversonKyle Iverson
    Participant

    Hi, the following function works until I specify a post_type: if ( $post->post_type == 'proposal' )

    function proposal_textarea_rows( $settings ) {
        global $post;
    
        if ( $post->post_type == 'proposal' ) {
            $settings['textarea_rows'] = 3;
        }
    
        return $settings;
    }
    add_filter( 'rwmb_wysiwyg_settings', 'proposal_textarea_rows' );
    #40618
    PeterPeter
    Moderator

    Hello Kyle,

    The code below works as well on my demo site without using a condition to check the post type

    function proposal_textarea_rows( $settings ) {
        $settings['textarea_rows'] = 3;
        return $settings;
    }
    add_filter( 'rwmb_wysiwyg_settings', 'proposal_textarea_rows' );

    Can you please check this filter hook again in a fresh install of WordPress and install Meta Box only?

    #40637
    Kyle IversonKyle Iverson
    Participant

    Hi Peter,

    That's correct. The code works without using a condition to check the post type but it doesn't work when using a condition.

    I tried a clean install and made sure that I'm targeting the correct post type.

    #40647
    PeterPeter
    Moderator

    Hello,

    That means the global variable $post is not working in this case. You can follow the topic below to get the post type when editing or creating a new post.
    https://wordpress.stackexchange.com/questions/152677/how-do-i-know-the-current-post-type-when-on-post-php-in-admin

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.