Adding reusable blocks to headers, content or footers

Add a ACF relationship field to either a page, posts, event, other-CPT or options page.

Example add ‘footer_reusable_blocks’ to the options page

In the footer file:

<?php get_template_part( 'template-parts/panels/footer-reusable-blocks'); ?>

And in the ‘template-parts/panels/footer-reusable-blocks’ part:

if ( ! function_exists( 'gomo_additional_panels' ) ) :
	function gomo_additional_panels() { ?>	
		$posts = get_field('footer_reusable_blocks', 'option');
		if( $posts ): ?>
		    <div class="entry-content">
		    <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
		        <?php setup_postdata($post); ?>
		        <?php the_content(); ?>
		    <?php endforeach; ?>
		    <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
		<?php endif; ?>
<?php }

Search the site

Share this page:


Subscribe to get regular news and updates

  • This field is for validation purposes and should be left unchanged.