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, follow a link to our website’s DevTools page: https://crocoblock.com/freemium/tools/.
Find the plugin called Related posts as options, download it, then install and activate in the WP dashboard.
Afterward, choose to edit the Add new post forms and input the following settings to the newly-added Select field:
The relation key can be found in the JetEngine > Relations directory:
Save the changes to the field and update the Form. This is how the end result might look on the frontend: