• Hy is there a way to change block attributes defaults depending on the page where a block is loaded. I’m using dynamic blocks in my project, and in block registration, I have defined attributes that have some defaults.

    For example, color red on the title. If I would want to specify that default title color is blue, if the block is loaded in, let’s say custom post type, admin editor.

    Is there a way to do this?

    • This topic was modified 4 years, 2 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not a Requests and Feedback topic
Viewing 1 replies (of 1 total)
  • Hi,

    It’s possible, Pick the current context.
    For custom post type use the code below to get current post type
    get_post_type( get_the_ID() )
    For admin editor use the following code,

    $screen = get_current_screen();
    if ( $screen->parent_base == 'edit' ) {
        echo 'edit screen';
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Block attributes depending on the custom post type’ is closed to new replies.