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:

<?php 
if ( ! function_exists( 'gomo_additional_panels' ) ) :
	function gomo_additional_panels() { ?>	
		<?php 
		$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; ?>
		    </div>
		    <?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:

Newsletter

Subscribe to get regular news and updates

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