Is it possible to create a dynamic field within an Advanced Custom Field?

Asked

Viewed 398 times

1

I need to create a field dynamic pulling information from the database that will be relating teachers and their characteristics and putting this field as ACF [Advanced Custom Fields] within a UI CPT [Custom Post Type] so-called teachers.

The only thing I need to know is how to create this dynamic field.

It will probably be through a function within the functions.php which will link this data and then activate the get_field within the CPT articles.

inserir a descrição da imagem aqui

1 answer

2


It is possible, yes. You will need to include Javascript/jQuery on this page and "listen" to changes in the dropdown. The changes will trigger Ajax calls and update the ACF Meta Box dynamically.

It’s not a little code or simple. ACF also has some very specific nomenclatures for pits and Fields that creates in the backend, and will need to inspect the DOM carefully to know the correct Ids.

This one is an example very close what you need: Display live preview of page on Hover in WP admin using ACF Relationship field.

Two other related:

PS: it is very important to create your own plugins to do this kind of thing, and not the functions.php; when you decide to change Theme, will thank you very much. Time to search for bugs too. See: Where do I put the code snippets I found here or Somewhere Else on the web?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.