I have some custom fields which are a repeater field..
I have them displaying in a sidebar of the page via a shortcode
function green_shortcode() {
ob_start();
?>
<div class="-sidebar-green"> <div class="sidebar-green-header">
<h3>Downloads</h3>
</div>
<?php
$child_posts = toolset_get_related_posts( get_the_ID(), 'download-link', array( 'query_by_role' => 'parent', 'return' => 'post_object' ) );
foreach ($child_posts as $child_post)
{ ?>
<div class="sidebar-green-link sidebar-link">
<div class="image">
<img src="<?php echo types_render_field( "file-type", array( "id"=> "$child_post->ID")); ?>"></div>
<div class="link">
$child_post->ID, "output" => "raw")); ?> ">
post_title; ?>
</div></div>
<?php } ?>
</div>
<?php
return ob_get_clean();
}
add_shortcode( 'green', 'green_shortcode' );
it all shows fine, However. The order is not the same on frontend as it is on the backend..
We used the drag drop order on back end to be:
A
C
D
F
B
E
On the front end they are more like
A
B
C
D
E
F
How do we order by?
I have already looked here https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts
Thanks
Hello and thank you for contacting the Toolset support.
Can you try by settings the order for toolset_get_related_posts to 'rfg_order' as described in the documenation:
$child_posts = toolset_get_related_posts(
get_the_ID(),
'download-link',
array(
'query_by_role' => 'parent',
'return' => 'post_object',
'orderby' => 'rfg_order',
'order' => 'ASC'
)
);