I have two custom posts

Custom post-type A  -> Custom field "enable or disable" 
Custom post-type B  -> Custom field "enable or disable"

I am using the ACF for making the custom fields I want to link both custom post types... if enabled in custom post type B then enable it in custom post type A. So basically i want custom post type A to be controlled by B .

Is it possible to link? How can i achieve this? Pls help Thanks

  • Why not add it to an options page? It would make more sense (to me, at least, from what I've read) to have an options page which controls the one field, across both post tyes ... why do you need to control the field from the post-type itself? – admcfajn Oct 16 '18 at 14:52
  • @admcfajn because options are fixed ..i need dynamic fields – Latheesh V M Villa Oct 16 '18 at 15:12

Can you please elaborate some more? Is this custom field possibly an ACF field? For what is this custom field tied, for a single custom post? And should this linking impact all of the posts in both post types?

(Sorry, but I don't have rights to make comments yet)

Supposing all of that, what I would suggest and probably do, is to create an ACF Options page and add this custom field there.

if( function_exists('acf_add_options_page') ) {     
        'page_title' => 'Options'

And then you can easily add the check for this field value on any place using function $value = get_field( 'your_custom_field', 'options' );

If what I supposed is wrong, please add some comments and correct me. There is a possibility to do exactly what you asked by using action hook save_post, but I just don't think that would be such a great idea. You would have to take the custom field value from the current post, and then loop through all of the posts in both post types and alter the value there as well.


Since I got it all wrong what was the intention of the OP, which was actually this:

How to update the value of one ACF field when updating another

Here is the correct answer. Use the acf/update_value hook, in combination with update_field() function:

function wpse316844_on_custom_field_save( $value, $post_id, $field  ) {

    // do some checks to see if the field is the one you want

    update_field( 'another_custom_field', $value, $other_post_id )


add_filter('acf/update_value/name=custom_field_name', 'wpse316844_on_custom_field_save', 10, 3);
| improve this answer | |
  • Hello thanks for the answer, i dont make the question offtopic by making it ACF related that's why i didn't added it in question .. yes it's related to ACF ..i am having a custom field for woocommerce product and if a customer buys it , the customer will be allowed to add a custom post. i want to make the customer entry to be unique by passing a the custom field value in woocommerce product to the custom post created by the customer – Latheesh V M Villa Oct 16 '18 at 13:43
  • @LatheeshVMVilla Do you mean something like reviews restricted only to the users who bought the item? – dboris Oct 16 '18 at 13:50
  • yeah.. think as listing ..the listing added by user based on the product he purchases. Allow promotion of listing if purchased product allows it. – Latheesh V M Villa Oct 16 '18 at 13:54
  • once a product is purchased the custom filed value in the product gets assigned to listing added by the customer – Latheesh V M Villa Oct 16 '18 at 13:55
  • 1
    @LatheeshVMVilla Have you checked this update_value ACF hook? Perhaps it does what you need. – dboris Oct 16 '18 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.