How to check if a block has alignfull using a conditional?


Are there any conditional queries to check if a block has an alignfull class for example?

I’m using the below which when part of another function adds the color overlay class to my body classes, but ideally this should only happen if the block is set to alignfull.

if ( 'core/cover' === $blocks[0]['blockName'] ) {

    // Would like to check if this block is set to alignfull before adding the below.
    if ( isset( $blocks[0]['attrs']['overlayColor'] ) ) {
        $classes[] = 'has-' . $blocks[0]['attrs']['overlayColor'] . '-header';


Thanks in advance 🙂

in progress 0
, Jamie Mitchell 1 year 2020-08-10T04:11:24-05:00 1 Answer 53 views 0

Answer ( 1 )


    Hi there,

    Yes, there is something you can use to check if a block is alignfull. There is an attribute to see if the block you are checking it’s been aligned full.

    In your case I would use (in fact, is  what I’m using these days on my starter Genesis  Theme):


    function genesis_first_block_body_classes( $classes ) {

    if ( $blocks[0][‘blockName’] === ‘core/cover’ && $blocks[0][‘attrs’][‘align’] === ‘full’ ) {

            $classes[] = ‘first-block-cover-full’;


    return $classes;



    This checks if the first block is a cover block and it’s been aligned with full-width. Then it adds the designated class to the body. Of course, you can whatever class you want to.

    I hope that helps.

Leave an answer