Hi,
I’m using the Post Slider module with an ACF relationship field on a custom post type (named Resource) to show related Resources on a single Resource Beaver Builder page. This works fine, unless the ACF relationship field for a Resource is blank (none selected). Then the slider defaults to all Posts. Is there a way around this?
Thanks!
I’ve found a way around this by creating a shortcode that first checks to see if the ACF relation field has Posts, and if it does, output the slider using the BB shortcode format:
add_shortcode('ni-related-materials', 'ni_related_materials');
function ni_related_materials() {
$posts = get_field('related_materials');
//if we have related materials
if( $posts ){
//return header
$output = do_shortcode('[fl_builder_insert_layout slug="related-resources-header"]');
//return related materials posts slider
$output .= do_shortcode('[fl_builder_insert_layout slug="related-resources"]');
return $output;
}
}
This works, except when viewing the page, the slider js doesn’t seem to be loading. If I add another posts slider to the page, the Related Materials slider functions, if not, the posts are shown, but not formatted into a slider. Any help with this part?
1 Like
Must have been a cache issue, as the slider is now working with the above code.