Types plugin provides a fields API, making it easy to display custom fields on your website’s front-end. The corresponding function call outputs the desired fields with a special formatting and supports different attributes for each field type.
Viewing 15 topics - 241 through 255 (of 264 total)
Problem: I have two post types in a one-to-many relationship. I would like to create a custom search View of the child post type, filtering by distance based on an address field in the parent post type, and include other filters based on custom fields in the child post type.
Solution: A View of post type A cannot filter by fields in post type B, so you would have to copy the parent address field into the child posts automatically using custom code, then filter by the address field in the child post type.
Problem: I would like to use a custom field from a related post to generate a dynamic link in the child post template. The Types field shortcode for this field is not returning any value.
Solution: You can use the Types field shortcode to output information from a related post using a special syntax in the "item" attribute, like this:
Problem: I would like to know whether I should use a Post Reference field or a Post Relationship, and understand the differences between the two.
Solution: A post reference field is a very simple version of a one-to-many (O2M) relationship. In the database, they are handled identically. The main differences are how they are managed in wp-admin. For example, with a O2M relationship between Clients and Vehicles, you can edit the parent Client post and see all the child Vehicle posts easily in the post relationship editor panel. If you want to disconnect one of the Vehicle posts, you can do it from the Client post. However, with a post reference field, you cannot easily manage the related Vehicles from the Client post. You would have to edit each Vehicle post to change the post reference Client. So if you want more management capabilities in wp-admin, you should use a O2M relationship. If you do not need this type of management, you can use a Post Reference field instead.
If you need the ability to create multiple Client post references in the same Vehicle post, you should use a M2M relationship instead of a repeating post reference field.