Title: wp_query repeating blocks
Last modified: June 27, 2022

---

# wp_query repeating blocks

 *  [jduffell](https://wordpress.org/support/users/jduffell/)
 * (@jduffell)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/wp_query-repeating-blocks/)
 * Hi, I’m using a wp_query to pull through the content of a custom post type.
 * I’m using the_title & the_content.
 * the_title works perfectly, eg – “post1”, “post2”, “post3” etc
 * the_content however is pulling through a custom block from the first post and
   then outputs the same content for the subsequent posts. Has anyone come across
   this before?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Weboccult Technologies Pvt Ltd](https://wordpress.org/support/users/weboccults/)
 * (@weboccults)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/wp_query-repeating-blocks/#post-15774034)
 * Hi [@jduffell](https://wordpress.org/support/users/jduffell/) Can you please 
   share your wp_query code so we can help you more precisely? Also share your loop
   where your are displaying title and content.
 * Thank you
    -  This reply was modified 3 years, 9 months ago by [Weboccult Technologies Pvt Ltd](https://wordpress.org/support/users/weboccults/).
 *  Thread Starter [jduffell](https://wordpress.org/support/users/jduffell/)
 * (@jduffell)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/wp_query-repeating-blocks/#post-15774047)
 * [@weboccults](https://wordpress.org/support/users/weboccults/) sure can 🙂
 *     ```
       <?php $args = array(
       	'post_type' 	=> 'case-study',
       	'nopaging' 		=> true,
       	'orderby' 		=> 'date',
       	'order' 		=> 'asc',
       	'paged' 		=> $paged,
       ); $wp_query = new WP_Query($args);
       if($wp_query->have_posts()) :
       while($wp_query->have_posts()) :  $wp_query->the_post(); 
   
       the_content();
   
       endwhile; else: ?>
   
       <span class="content">
   
       	Sorry, no matching case studies could be found
   
       </span>
   
       <?php endif; wp_reset_query(); ?>
       ```
   
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/wp_query-repeating-blocks/#post-15774842)
 * I see no problems there. I tested it on my own site to be sure, only changing
   the CPT to one of my own. The issue lies elsewhere. Is your custom block pulling
   content from elsewhere? That could be the issue. the_content() output is filtered.
   It’s possible an added filter is using the same content in every post.
 *  Thread Starter [jduffell](https://wordpress.org/support/users/jduffell/)
 * (@jduffell)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/wp_query-repeating-blocks/#post-15776868)
 * [@bcworkz](https://wordpress.org/support/users/bcworkz/) Nothing I can spot, 
   I’ve stripped out any additional code and it appears to be doing the same, I 
   am using the Advanced Custom Fields plugin, but aside from that, it’s a bit of
   a head scratcher. A long work around I’ve found is within the loop to parse the
   blocks, however I’m having to print values from an array into the relevant elements
   which is long winding and means additional code which is a bit of a pain.
 *     ```
       add_action('acf/init', 'my_acf_init_block_types');
       function my_acf_init_block_types() {
   
           if( function_exists('acf_register_block_type') ) { 
   
               acf_register_block_type(array(
                   'name'              => 'case-study',
                   'title'             => __('Case Study'),
                   'description'       => __('Predefined case study layout'),
                   'render_template'   => 'templates/parts/block-case-study.php',
       			'enqueue_assets'  => function() {
       				wp_enqueue_style( 'css', get_template_directory_uri() . '/style/case-study.css' );
       			},
                   'category'          => 'formatting',
       			'icon' 				=> array(
       				'background' 		=> '#9FFF9F',
       				'foreground' 		=> '#000000',
       				'src' 				=> 'layout',
       				),
                   'mode'				=> 'edit',
               ));
   
           }
       }
       ```
   
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/wp_query-repeating-blocks/#post-15778586)
 * Sadly the inner workings of blocks is beyond my comprehension. I suspect there
   is a flaw in the block’s render code where what the current post is in your loop
   isn’t getting through to the code. It keeps getting ACF data related to the first
   post and never gets updated about subsequent posts. But I’m only guessing since
   I don’t understand the inner workings.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘wp_query repeating blocks’ is closed to new replies.

## Tags

 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 5 replies
 * 3 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [3 years, 9 months ago](https://wordpress.org/support/topic/wp_query-repeating-blocks/#post-15778586)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
