Created
April 20, 2016 21:39
-
-
Save davidzack/28965d5375c51f238281ccacbe339062 to your computer and use it in GitHub Desktop.
ACF slider post object
This file contains 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
//wrap action in condition to show ONLY if ACF is active, avoiding errors | |
if( class_exists('acf') ) { | |
add_action( 'genesis_before_content', 'dz_output_slick_slider' ); | |
} | |
function dz_output_slick_slider() { | |
$post_object = get_field('select_a_slider'); | |
//$post_object_id = $post_object->ID; | |
if( $post_object ): | |
//* Add gallery slider function | |
echo '<div class="slick-slider clearfix">'; | |
foreach( $post_object as $post): // variable must be called $post (IMPORTANT) | |
setup_postdata($post); | |
//this is where I'll want to loop through the custom fields of each slide that is selected by the slider post object field | |
echo the_title(); | |
endforeach; ?> | |
<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?> | |
<div> | |
<?php endif; | |
echo '</div>'; | |
echo '</div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment