I have created some custom fields with Advanced Custom Fields and set them to appear in my custom post type named X (post type is equal to X).
But I only need them to display on a particular single page from this custom post type, not on all of them.
How would I do that?
Couldn’t you do this through ACF settings page? You can select Post and set it equal to the title.
Edit
Updated image for clarification
Edit 2
It turns out ACF does not query for custom type when display the title drop down. To include all post type, in /core/admin/meta_box_location.php, change
To
If you are referring to removing certain fields that you have added via PHP on post.php or post-new.php, when the post type meets a certain condition, then you can use the acf_remove_local_field( $key ) function – see https://www.advancedcustomfields.com/resources/register-fields-via-php/
I went with something along these lines:
I found that only adding the specific fields on specific admin screens broke some of the Ajax lookup functions, hence adding to all and then removing from specific admin screens.
There is probably a much more efficient way to do this, but this is working for me.
The following is a more efficient method:
This checks for both EDIT and ADD screen and uses the “acf_remove_local_field($key)” function to remove the selected field by the key.