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


Address

123 Main Street
Town
City
P05T C0D3

Tel: 01234 567 899

Mob: 01234 567 899

Email: ben@gomopress.com


Copyright 2023. Blah blah blah Company Limited