I have a requirement to create repeating full-width blocks, with a customisable background colour and intro text. Within these blocks, I need another repeating group of info panels, containing a hyperlinked image overlaid with text. I'm creating this programatically, not using Views, and I can get the main blocks to repeat correctly, but the nested loop within them isn't outputting anything. I suspect there's a problem with the toolset_get_related_posts syntax on the inner loop.
My code is as follows:
<!-- OUTER LOOP -->
<?php
$child_posts = toolset_get_related_posts( get_the_ID(), 'campaign-block', array( 'query_by_role' => 'parent', 'return' => 'post_object' ) );
foreach ($child_posts as $child_post)
{ ?>
[BLOCK TITLE AND TEXT OUTPUT HERE, ALL WORKS FINE, AND REPEATS CORRECTLY]
<!-- INNER LOOP -->
<?php
$child_posts_blocks = toolset_get_related_posts( get_the_ID(), 'block-info-panels', array( 'query_by_role' => 'parent', 'return' => 'post_object' ) );
foreach ($child_posts_blocks as $child_post_block)
{ ?>
[NOTHING BEING OUTPUT IN THIS LOOP!]
hidden link
<?php }?>
<?php wp_reset_query(); ?>
<!-- /INNER LOOP -->
<?php }?>
<?php wp_reset_query(); ?>
<!-- /OUTER LOOP -->
Would appreciate any pointers. Pretty sure it's just the syntax on that inner loop that needs fixed.
Resolved it myself. Inner loop was querying the wrong ID. Changed it to this:
$child_posts_blocks = toolset_get_related_posts( $child_post->ID, 'block-info-panels', array( 'query_by_role' => 'parent', 'return' => 'post_object' ) );
And it's now working. 🙂
My issue is resolved now. Thank you!