Is there a way to display the posts’ “Relation” meta field on the frontend Add new post form?
Let’s imagine that you run a property listing website, storing 2 major custom post types – Agents and Properties. The properties are submitted through a frontend form. You would like the site users to be able to select which agent a particular property is related to via a frontend form. For that reason, you’ve created the relationships between the Properties and Agents CPTs. Now, it’s time to find out how you can display just the Relation meta field in the frontend form.
The answer to that is a Select field. You could add such a field to the form where you want to output and choose the related posts.
Firstly, choose to edit the Add new post form, add a new Select field to it and configure it as follows:
Then move on to the Post-submit Actions / Notification Settings section, open the Insert/Update Post notification type, and set up the Select field you’ve added previously. In the Fields Map section, find the necessary field, then choose the “Post Meta” option in the Select post property drop-down. Once there’s a new empty text area next to it, paste the relation meta key into it:
NOTE. The relation meta key can be found in the JetEngine > Relations directory:
Save the changes to the field and the notification type, then update the Form. This is how the end result might look on the frontend: