What are blocks?
Blocks are designed and coded content components that are placed onto a page to makeup a complete webpage.
Typically we use acf blocks to create our own page builder
- Blocks are reusable
- Blocks are orderable
- Blocks hold content which is easy to edit
- blocks take the complexity out of content entry
what is the acf block builder?
Text with image
Could also be two column content, both columns should capable of containing an image
fields
- wysiwyg
- image
- link
Image gallery with lightbox
fields
- wysiwyg
Grid
fields
this could be one row of 3 boxes or 3 rows of 3 boxes
- repeater
- wysiwyg
- image
- link
Testimonial slideshow
- repeater
- text
- textarea
cards
- image
- textarea
- link
accordion
often used for faq’s
fields
- repeater
- title
- text
anchor links
links that link the user to content on the page
fields
- repeater
- links
cta strip
fields
- link
- text
subscribe strip
- form field
- text
The beauty of the ACF flexible content blocks page builder is simplicity and ease of use for administrators.
As the page builder blocks are built using custom fields that map directly to the page content. there is very little room for error.
From our WordPress Training experience teaching a client to use a simple acf flexible content page builder is the easiest form of training to conduct.
This approach is great for building simple sites without too many pages and without too many blocks.
For Developers
/**
* function to output page builder blocks or only return list of blocks
*/
function acf_display_pb_blocks(){
$blocks = array(
'content_with_image',
'client_logos',
'spacer',
'btns',
'cards',
'safety',
'testimonial-slider',
'projects',
'cta',
'blog_posts',
'protecth',
);
if( have_rows('blocks') ):
while ( have_rows('blocks') ) : the_row();
$layout = get_row_layout();
if( in_array( get_row_layout(), $blocks ) ){
get_template_part( 'template-parts/blocks/block', $layout );
}
endwhile;
endif;
}
//add this function to the page
<?php
acf_display_pb_blocks();