function add_meta_field_to_acf_relation($title, $post, $field, $post_id){
return str_replace('</div>', '</div> <strong>'.get_field('objectnumber',$post->ID).': </strong>', $title);
}
add_filter('acf/fields/relationship/result', 'add_meta_field_to_acf_relation',10,4)
add_image_size( 'acf-thumb', 21, 21, true );
function acf_relationship_thumbnails($title, $post, $field, $post_id){
if( in_array('featured_image', $field[‘elements’]) ) {
$image = '';
if( $post->post_type == 'attachment' ) {
$image = wp_get_attachment_image( $post->ID, 'acf-thumb' );
} else {
$image = get_the_post_thumbnail( $post->ID, 'acf-thumb' );
}
$title = preg_replace("/(.*\<div class=\"result-thumbnail\"\>)(.*)(\<\/div\>.*)/", "$1$image$3", $title);
}
return $title;
}
add_filter('acf/fields/relationship/result', 'acf_relationship_thumbnails', 10, 4);
Författare: Erik
Erik har jobbat med webb professionellt sedan 2008. Från 2005 till 2008 studerades webb på ING/JTH och dessförinnan skapades webb på all fritid. Första sajten byggdes någon gång mellan 1996-1998.
Visa alla inlägg av Erik