Last active
June 6, 2017 10:32
-
-
Save BinaryKitten/db96c4acb8427007acfb62476108c315 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function render_acf_content( $field_name = 'page_layout', $post_id = null ) { | |
| if ( ! $post_id ) { | |
| $post_id = get_the_ID(); | |
| if ( is_home() ) { | |
| $post_id = get_option( 'page_for_posts' ); | |
| } | |
| } | |
| $render_block = function () { | |
| $row_layout = get_row_layout(); | |
| $templates = array( | |
| apply_filters( 'template_include', "content_blocks/block-{$row_layout}.php" ), | |
| apply_filters( 'template_include', 'content_blocks/block.php' ), | |
| ); | |
| $located = locate_template( $templates, false, false ); | |
| if ( (string) $located !== '' ) { | |
| include $located; | |
| } elseif ( WP_DEBUG ) { | |
| echo '<strong>' . $row_layout . '</strong>'; | |
| } | |
| }; | |
| if ( have_rows( $field_name, $post_id ) ) { | |
| $row_index = 0; | |
| while ( have_rows( $field_name, $post_id ) ) { | |
| the_row(); | |
| $render_block(); | |
| $row_index ++; | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| get_header(); | |
| while ( have_posts() ) : | |
| the_post(); ?> | |
| <div id="mainWrap"> | |
| <?php render_acf_content(); ?> | |
| </div> | |
| <?php | |
| get_footer(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment