Skip Navigation

[Resolved] Creating Custom Post Type for Specific Connections

This support ticket is created 6 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 6 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#1109616
IMG_0333-io.JPG

Tell us what you are trying to do?

I'm creating a database for hiking trailheads. Each trailhead has attached "services" such as restaurants, camping locations, etc.

Some services are used for more than one trailhead.

So (see picture), in my drawing I have one restaurant that is connected to three trailheads (A, B, and C).

I want to show users how far away the restaurant is from each of the three trailheads.

So, the Restuarant connects to Trailhead A, and is 12 miles away.

So, the Restuarant connects to Trailhead B, and is 1.7 miles away.

So, the Restuarant connects to Trailhead C, and is 3.7 miles away.

I'm only using a single Restaurant record, and three trailhead records.

So, I need a record that adds data based upon the specific connection (i.e. Restaurant to Trailhead A, Restaurant to Trailhead B, or Restaurant to Trailhead C). That record that is based upon the specific connection would connect to the appropriate Restaurant and trailhead, and contain a number field for the distance.

I'm not sure the best way to configure this "Distance to Trailhead" post type.

When I show the trailhead information, and the connected services (i.e. restaurants, camping locations, etc.) I want to show the distance from the trailhead to each service based upon the trailhead and the service.

What's the best way to do this?

Thank you!
Andy

#1110300

Hello,

I assume each "trailheads" has a static address, I suggest you try these:
1) setup two post types: "trailheads" and "Restuarant",
https://toolset.com/documentation/user-guides/create-a-custom-post-type/

2) create many-to-many relationship between post types "trailheads" and "Restuarant",
https://toolset.com/documentation/post-relationships/

3) Create a custom address field "location", register it to both post types "trailheads" and "Restuarant".
https://toolset.com/documentation/user-guides/how-address-fields-work-in-cred-forms/

4) In a single "Restuarant" post, you can create a view to get all related "trailheads" posts:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items, in the view's loop, display below custom shortcode [Distance-to-Trailhead]:
Create a custom shortcode [Distance-to-Trailhead]:
Get the address field "location" values from "Restuarant" post and current "trailheads" post, and calculate the distance between "Restuarant" and "trailheads".
https://codex.wordpress.org/Function_Reference/add_shortcode