Adding Custom Fields linked to Custom Post Type
-
Hi,
I’m massively using Types on a website I’m working on since it’s really easy and powerfull.
I have 2 Custom Posst, let’s call them “Book” and “Authors” .In the edit panel for a Book, I would like to add a custom field “Author” wich would be a dropdownlist with the author associated to the book.
I’m wondering how to achieve this, ie the dropdown list should retrieve all Authors, show them and store (for ex) the ID of the selected author.
Of course, this is an example, the project is a bit more complex (so that I can’t use taxonomy “author”, or use the parent relations built in types).
Is ther a way to acheive this (without the use of Views, indeed)
Thanks in advance.
-
Dear lorembolo
You can setup CPT “Author” as a parent to “Book”. See this example: http://wp-types.com/documentation/user-guides/creating-post-type-relationships/
This data is stored as post meta for book in custom field key:
_wpcf_belongs_authir_id. If Author CPT hasauthorslug.Marcin
Thanks for your answer Marcin.
As I mentionned, I can’t use the parent relationship for this use. (it(s more complicated than the description above)
Ther is no other way to achieve this ? I heard of post2post or ACF relationship, they seem to do what I want…
And, by the way, I already use the relationship beetween 2 CP, but, the meta box showing is not really user friendly.
It shows the slug of the taxonomy, instead of its name, and the message is not really clearDear lorembolo
You can fill select using
wpt_field_optionsfilter. See this example: https://wordpress.org/support/topic/user-select-field?replies=2#post-6191259Maybe it could help?
Marcin
The topic ‘Adding Custom Fields linked to Custom Post Type’ is closed to new replies.