Skip to content

Instantly share code, notes, and snippets.

@davidzack
Created April 20, 2016 21:39
Show Gist options
  • Save davidzack/28965d5375c51f238281ccacbe339062 to your computer and use it in GitHub Desktop.
Save davidzack/28965d5375c51f238281ccacbe339062 to your computer and use it in GitHub Desktop.
ACF slider post object
//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