"Post" Field Type
Support › Meta Box AIO › "Post" Field TypeResolved
- This topic has 6 replies, 2 voices, and was last updated 2 years ago by
Peter.
-
AuthorPosts
-
April 13, 2023 at 2:48 PM #41474
richard rowles
ParticipantHi, I have Twwo CPTs A and B. A has a field of type "post" that lists all the posts of type B I would like to list in the select box a field in CPT-B that is not the title. Is this possible? Sorry I couldn't find out how to do this.
TIA Rich
April 13, 2023 at 8:04 PM #41481Peter
ModeratorHello Rich,
Sorry, I don't understand the question clearly. Can you please give more details or share some screenshots of this?
April 13, 2023 at 8:19 PM #41484richard rowles
ParticipantNot at PC right now, but
1) when you add a Field to a field group one option is to use the "Type" of "Post"
2) then in the "Post Types" box I can add the post type that I want to be used.
3) for "field type" I choose "select".So in this drop down I have a list of posts of the type i have choosen, which is absolutley correct.
The issue is that it only displays the post titles in the select box. What I need to do is to have different field displayed in the box.
I was thinking I might be able to use "query args" to specify which field and value I retrieve to display in the box but I can't get it to work.
I this example I'm not using title at all. So from the CPT called "contact" I need the "name" field from that CPT to list in the box.
Does that make sense?
Thanks Rich.April 14, 2023 at 5:45 PM #41497Peter
ModeratorHello,
I understand the question. Unfortunately, Meta Box does not support displaying other field values in the select box, only the post (object) title will be displayed.
April 14, 2023 at 6:32 PM #41498richard rowles
ParticipantThanks Peter, Is there a way with metabox or a component it works with to copy one field to another either before a new/edit submit button is pressed that way I could copy the "name" field to the CPT Title?
Best
RichApril 14, 2023 at 7:31 PM #41499richard rowles
ParticipantSolution Found: Quite usefull maybe?
Using "Adminify" I added this code to the footer
1) It hides the title and slug for the post.
2) it copies from the required field to the title input box.NB: I will add page name based if statment to only activate on the correct page.
RESULT: "post select dropdown" now has the value of a field I need to display in the dropdown. 🙂
document.getElementById('post-body-content').style.height=0;
document.getElementById('post-body-content').style.padding=0;
document.getElementById('post-body-content').style.margin=0;document.getElementById('name').addEventListener('keyup', function (event) { document.getElementById('title').value = event.target.value});
Best Rich
April 16, 2023 at 9:26 PM #41508Peter
ModeratorThank you for sharing the solution.
-
AuthorPosts
- You must be logged in to reply to this topic.