Skip to content

Instantly share code, notes, and snippets.

@besimhu
Last active August 29, 2015 14:25
Show Gist options
  • Save besimhu/de2e2cd52bc5864d9c5b to your computer and use it in GitHub Desktop.
Save besimhu/de2e2cd52bc5864d9c5b to your computer and use it in GitHub Desktop.
Get ACF flexible content without using ACF functions.
<?php
// get post ID
$pid = get_the_ID();
$flex_rows = get_post_meta( $pid, 'acf_flex_content', true );
if ( !empty($flex_rows) ) {
foreach( $flex_rows as $count => $row ) {
switch( $row ) {
// if flex module one
case 'flex_one':
$field_one = get_post_meta( $pid, 'acf_flex_content_' . $count . '_field_one', true );
$field_two = get_post_meta( $pid, 'acf_flex_content_' . $count . '_field_two', true );
include 'partials/flex-one.php';
break;
// if flex module two
case 'flex_two';
$field_one = get_post_meta( $pid, 'acf_flex_content_' . $count . '_field_one', true );
$field_two = get_post_meta( $pid, 'acf_flex_content_' . $count . '_field_two', true );
include 'partials/flex-two.php';
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment