Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php // I intentionally didn't re-indent your code
- $post_objects = get_sub_field('choose_blocks');
- $string = array(); // array of post IDs
- if( $post_objects ): ?>
- <?php foreach( $post_objects as $post_object):
- $post_id = $post_object->ID;
- $string[] = $post_id;
- endforeach; ?>
- <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
- <?php endif; ?>
- <?php
- $args = array(
- 'post_type'=>'presentations',
- 'post_status'=>'publish',
- 'post__in' => $string
- );
- ?>
- <?php // the query
- $all_presentations = new WP_Query($args); ?>
- <?php if ( $all_presentations->have_posts() ) : ?>
- <?php while ( $all_presentations->have_posts() ) : $all_presentations->the_post(); ?>
- <?php get_template_part( 'includes/content', get_post_format() ); ?>
- <?php endwhile; ?>
- <!-- end of the loop -->
- <?php wp_reset_postdata(); ?>
- <?php else : ?>
- <!-- do nothing -->
- <?php endif; ?>
- <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement