SHARE
TWEET

Untitled

a guest Aug 30th, 2018 2 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php // I intentionally didn't re-indent your code
  2.  
  3. $post_objects = get_sub_field('choose_blocks');
  4. $string = array(); // array of post IDs
  5. if( $post_objects ): ?>
  6.  
  7.     <?php foreach( $post_objects as $post_object):
  8.  
  9.         $post_id = $post_object->ID;
  10.  
  11.         $string[] = $post_id;
  12.  
  13.  
  14.     endforeach; ?>
  15.  
  16.     <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
  17. <?php endif; ?>
  18.  
  19.  <?php
  20.      $args = array(
  21.         'post_type'=>'presentations',
  22.         'post_status'=>'publish',
  23.         'post__in' => $string
  24.     );
  25. ?>
  26.  <?php // the query
  27.     $all_presentations = new WP_Query($args); ?>
  28.  
  29.     <?php if ( $all_presentations->have_posts() ) : ?>
  30.  
  31.         <?php while ( $all_presentations->have_posts() ) : $all_presentations->the_post(); ?>
  32.  
  33.             <?php get_template_part( 'includes/content', get_post_format() ); ?>
  34.  
  35.         <?php endwhile; ?>
  36.         <!-- end of the loop -->
  37.  
  38.  
  39.         <?php wp_reset_postdata(); ?>
  40.  
  41.     <?php else : ?>
  42.        <!-- do nothing -->
  43.     <?php endif; ?>
  44.  
  45. <?php endif; ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top