Schalk Joubert
Schalk Joubert

Reputation: 398

Add ACF fields to Post Edit Admin Page / edit.php

I am trying to add a few custom fields to the edit.php page ( Post List Page ) It is a few settings like asking the user whether post must be displayed in 2,3 or 4 columns w, and I specifically want it on this page.

I have found a way to add content with a function to the right place without editing the wp-admin/edit.php or 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>';
        });
});

i am also halfway in adding a location rule in 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;    
}

But how do now create a location rule to show my ACF fields here?

Thank you enter image description here

Upvotes: 0

Views: 1695

Answers (1)

nomad-mystic
nomad-mystic

Reputation: 11

I spent hours trying to extend the ACF_Location class without success.

The ACF Extended WordPress plugin provides the desired functionality.

You can find the GitHub repo here.

I believe this is the class that extends the ACF location functionality we both needed. @see acfe_location_post_type_archive class here

Upvotes: 1

Related Questions