Hi @simoneboccuzzi,
To change the way relationship field output is displayed on then you have to add some code in your function.php in your theme or child-theme.
I do not really know anything about the code snippet plugin so do not know if you can insert the code here as well.
But I have made some code as you can see here which makes the relationship field a comma seperate list
add_filter( 'acfvc_relationship', 'acfvc_custom_relationship', 10, 3 );
function acfvc_custom_relationship ( $output, $field, $post_id ) {
$posts = $field["value"];
$output = "<div>";
foreach($posts as $key => $post_details) {
$post_id = $post_details->ID;
$output .= '<a href="'.get_permalink($post_id).'" title="'.get_the_title($post_id).'">'.get_the_title($post_id).'</a>';
if ( $key != array_key_last( $posts ) ) {
$output .= ', ';
}
}
$output .= "</div>";
return $output;
}
Hope it can help you, otherwise feel free to write again.
Best regards
Frederik
Thank you so much for your help, your time and your quick response.
Unfortunately the code doesn’t work. I hope you can help me again.
I attach a screenshot of what happens. Thank you!
Screen
https://share.getcloudapp.com/d5uEqXPY
I would like something like this:
https://share.getcloudapp.com/jkuZGpXX
HI @simoneboccuzzi,
I just changed the code a bit so it should work.
If it does not then I do not quite know what I can do as both codes I have sent work on my development environment.
add_filter( 'acfvc_relationship', 'acfvc_custom_relationship', 10, 3 );
function acfvc_custom_relationship ( $output, $field, $post_id ) {
$posts = $field["value"];
$output = "<div>";
$count = count( $posts );
$i = 1;
foreach($posts as $key => $post_details) {
$post_id = $post_details->ID;
$output .= '<a href="'.get_permalink($post_id).'" title="'.get_the_title($post_id).'">'.get_the_title($post_id).'</a>';
if ( $i < $count ) {
$output .= ', ';
}
$i++;
}
$output .= "</div>";
return $output;
}