【问题标题】:Add ACF fields to Post Edit Admin Page / edit.php将 ACF 字段添加到 Post Edit Admin Page / edit.php
【发布时间】:2020-07-27 00:44:28
【问题描述】:

我正在尝试向 edit.php 页面(帖子列表页面)添加一些自定义字段 这是一些设置,例如询问用户帖子是否必须显示在 2,3 或 4 列 w 中,我特别希望在此页面上显示。

我找到了一种无需编辑 wp-admin/edit.php 或 wp-admin/custom-header.php 即可将内容添加到正确位置的方法

add_action( 'load-edit.php', function(){
   $screen = get_current_screen(); 
   if( 'edit-post' === $screen->id )
   {
        add_action( 'all_admin_notices', function(){
            echo '<h2> === Add ACF Fields here === </h2>';
        });
});

我也在 ACF 中添加位置规则的一半:

add_filter('acf/location/rule_types', 'acf_location_rules_types');
function acf_location_rules_types( $choices ) {
     $choices['Post']['post_edit_screen'] = 'Post Edit Screen';
    return $choices;    
}

但是现在如何创建位置规则以在此处显示我的 ACF 字段?

谢谢

【问题讨论】:

标签: advanced-custom-fields acfpro


【解决方案1】:

我花了几个小时试图扩展 ACF_Location 类,但没有成功。

ACF Extended WordPress 插件提供了所需的功能。

您可以找到 GitHub 存储库here

我相信这是扩展我们都需要的 ACF 定位功能的类。 @见acfe_location_post_type_archivehere

【讨论】:

    猜你喜欢
    • 2018-06-18
    • 1970-01-01
    • 2013-01-25
    • 2019-07-14
    • 2022-01-21
    • 2016-08-15
    • 2020-05-13
    • 2018-03-05
    • 1970-01-01
    相关资源
    最近更新 更多