Troubleshooting //
How to Show Posts Relations in the Add New Post Frontend Form

How to Show Posts Relations in the Add New Post Frontend Form

Question

Is there a way to display the posts’ “Relation” meta field on the frontend Add new post form?

Answer

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.

devtools plugin related posts as options

Afterward, choose to edit the Add new post forms and input the following settings to the newly-added Select field: 

select meta field backend settings

The relation key can be found in the JetEngine > Relations directory:

copy the relation meta key

Save the changes to the field and update the Form. This is how the end result might look on the frontend:

related agents meta field

Was this article helpful?
YesNo
Still need help?
Submit a request