Hi @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
@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(); ?>
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.
@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',
));
}
}
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.