Home Forums General Issues Custom field within custom field?


Custom field within custom field?

  • I’m wondering if there’s a way to embed a custom field within a custom field? Let’s say, for example only, that I’m trying to build a simple Post structure, very similar to WordPress’s own, but implemented using ACF.

    First, I build a Post custom field, which has a text title and text area body. It also has a select field called “Category”, which I fill in with categories “A”, “B”, and “C” to choose from.

    I then want to add some more information to a Category, so I create a new Category custom field, containing a text title and a text area description. I then create three such Category fields, specifically “A”, “B”, and “C”.

    I can connect these programmatically by grabbing a particular post’s Category, then querying all Categories for the one whose title matches, and then grabbing the description from the resulting object – but that’s cumbersome, and adding a new Category requires both adding a custom Category custom field as well as adding it to the Select list on the Post custom field. Is there any way to arrange it so that the Post custom field has a Select whose values are the titles of the Category custom field?

  • It IS possible! Turns out it’s as easy as setting the custom field type to Relational -> Post Object, then setting the “Filter by Post Type” to “Category” (in my case). This makes it so that when I create a new “Post”, I have a dropdown of “Category” posts to choose from. Awesome!

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.