Skip to content

Instantly share code, notes, and snippets.

@dividezigns
Last active June 19, 2018 23:39
Show Gist options
  • Save dividezigns/92b2903d3fc23cf6cdc4a0fe1d0c0fdb to your computer and use it in GitHub Desktop.
Save dividezigns/92b2903d3fc23cf6cdc4a0fe1d0c0fdb to your computer and use it in GitHub Desktop.
This code will use ACF's relationship field to display a WP Forms. Place this code snippet in your single template file located in your child theme directory.
<?php
$posts = get_field('wp_forms');
if( $posts ):
foreach( $posts as $post):
$form_id = get_the_ID();
echo do_shortcode('[wpforms id="' . $form_id . '"]');
endforeach;
wp_reset_postdata();
endif;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment