Support

Account

Home Forums Gutenberg ACF Blocks and Condition if Exist

Solving

ACF Blocks and Condition if Exist

  • Hello,
    I’m creating ACF Blocks in my page.php but i want to add a PHP condition to allow to the user to add a container or not if there is a ACF Blocks is added here is a exemple to know more what i want to do

    if ( There is a ACF Blocks is in Guthenberg ) then
    <div class=”full-width”></div>
    elseif ( There is a simple Blocks in Guthenberg ) then
    <div class=”container”></div>
    endif

    Anyone can help me ?

  • Gutenberg are stored in the post content. I think this is not useful but did you tried to edit this in your template? If the Gutenberg block is already in a class of container like this you can add a full width and style it with CSS after.

    <div class="container">
      <div class="full-width guternberg-block">
       My Block
      </div>
    </div>
    style {
      .container {
        // this is a example
        width: 1200px;
      }
    
      .full-width {
         width: 100vw;
         position: relative;
         left: 50%;
         right: 50%;
         margin-left: -50vw;
         margin-right: -50vw;
       }
    }

    you can read more here https://css-tricks.com/full-width-containers-limited-width-parents/

  • Ok thank you, it can be kind of a quick solution

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.