好的,我最终找到了一个解决方案。以下是我使用的函数:
function add_custom_field_after_title($title, $id) {
if ( in_the_loop() ) {
$custom_field = get_field( \'customfield\', $id );
if ( !empty($custom_field) ){
$title .= $custom_field;
}
}
return $title;
}
add_filter(\'the_title\',\'add_custom_field_after_title\',10,2);