我想在我的帖子标题中添加一个ACF字段,仅在admin表中(不在数据库中存储的标题字段中),并且仅针对特定的自定义帖子类型。我的一些帖子有相同的名字,所以有这些信息会更有用。最后,我的标题如下:
$new_title = get_the_title($post->ID).\' - \'.get_field(\'place\', $post->ID);
我在其他主题上找到了其他解决方案,但所有的帖子类型都受到了影响。非常感谢。我想在我的帖子标题中添加一个ACF字段,仅在admin表中(不在数据库中存储的标题字段中),并且仅针对特定的自定义帖子类型。我的一些帖子有相同的名字,所以有这些信息会更有用。最后,我的标题如下:
$new_title = get_the_title($post->ID).\' - \'.get_field(\'place\', $post->ID);
我在其他主题上找到了其他解决方案,但所有的帖子类型都受到了影响。非常感谢。使用此选项可筛选标题:
add_action(
\'admin_head-edit.php\',
\'wpse264139_edit_post_change_title_in_list\'
);
function wpse264139_edit_post_change_title_in_list() {
add_filter(
\'the_title\',
\'wpse264139_construct_new_title\',
100,
2
);
}`
`function wpse264139_construct_new_title( $title, $id ) {
if(get_post_type($id) == \'post_type\') {
$field = get_field(\'place\', $id);
return $field . " " . $title;
}
else {
return $title;
}
}
注意:大多数代码来自:Replacing the title in admin list table我想把它完全去掉。不仅是“归档”标签,还有一切。它不应该出现。我已经找了几个小时的解决方案,但都没有用。请帮忙。非常感谢。