Ok,
I had a go at a few differnt things. Appologies in advance if my methods are a bit haphazard.
I tried a number of things including the following.
Going by the ACF example in Brick's Query Loop editor
$related_child_post_ids = toolset_get_related_posts (
get_the_id(),
'print-year_print',
'parent',
999,
0,
array(),
'post_id',
'child'
);
$current_post[] = get_queried_object_id();
return [
'post_type' => 'print', //e.g. faculty
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'related-field', // the ACF rel field
'value' => get_the_id(),
'compare' => 'LIKE'
)
),
'post__not_in' => $current_post,
];
I even tried the following:
$related_child_post_ids = toolset_get_related_posts (
get_the_id(),
'print-year_print',
'print-year',
999,
0,
array(),
'post_id',
'print'
);
$current_post[] = get_queried_object_id();
return [
'post_type' => 'print', //e.g. faculty
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'related-field', // the ACF rel field
'value' => get_the_id(),
'compare' => 'LIKE'
)
),
'post__not_in' => $current_post,
];
Each triggered a parse error in the Bricks builder.
I moved onto setting up your code example as a function in Fluent Snippets but this didn't wor out to well for me.
function GetPrintsOfYear($query) {
$related_child_post_ids = toolset_get_related_posts(
get_the_id(),
'print-year_print',
'parent',
999,
0,
array(),
'post_id',
'child'
);
return $query;
}
add_filter('pre_get_posts','GetPrintsOfYear');
Either this isn't the correct way about going about this or the hook is wrong?