Skip Navigation

[Resolved] How to create an input meta box for a list of urls which will be different

This support ticket is created 6 years, 10 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#535770
Screen Shot 2017-06-12 at 3.13.56 PM.png

I have a travel site. I have CPT for hotels. Some hotels have restaurants that are located on premises. These restaurants are open to the public, and therefore have their own pages on the site.

I want to create a list of "ON PREMISE DINING" on my hotel CPT. I want the entries on this list to link to the restaurant.

How do I make an empty box that allows me to add the url and the text with the name of the url to my content template?

I am building my own content templates because Layouts STILL does not work with Genesis.

Remember, this will be individual for each hotel. I want the link to come up in search results, but there will be hundreds of hotels, and so using a checkbox would be ridic.

Please let me know if I am making myself clear. I have attached an image that may or may not be illustrative. As you can see in the image, I have the ability to list amenities, which are common to all hotels, and also to list and group searchable things like "good for corporate meetings." These are different, because they are common to all of the hotel CPT.

What I need is a box, where I can list the text name and the url to link from the page to that particular post. This box needs to appear on all hotel CPTs, but won't always be used, and the value of the url will never be the same.

#535789

Hi, there are a couple of different ways to approach this so I'll try to give you a general overview. Then you can decide which works best for you, and I can give you more technical information.

Parent / Child relationships
I think this is the best option. You can use a parent / child relationship to associate restaurants with hotels. From the hotel editor in wp-admin, you will be able to associate existing restaurants with each hotel. You will be able to use an autosuggest text field, which will make it easier to find the restaurants. Once you make this parent/child relationship, then you can access relevant restaurant information from the parent hotel's Content Template.
One-to-many relationships are explained here:
https://toolset.com/documentation/toolset-training-course/part-8-one-to-many-relationships-in-toolset/

Custom Fields
This approach probably is not the most flexible approach, but is still an option. Create a new Custom Field for Hotels. In this custom field, you will store the ID of the Restaurant for this hotel. If you can have multiple restaurants, you must use a repeating custom field. Then in the Hotel content template, you can access that custom field to get information about each restaurant. This is a bit more tedious, since you would need to know each restaurant's ID when you edit a hotel. It's not really practical.
More information about custom fields can be found here:
https://toolset.com/documentation/user-guides/#types-topics

Let me know your thoughts and we can go from there.

#536975
Screen Shot 2017-06-15 at 1.09.19 AM.png

Thanks very much, Christian. I'd like to go w the first solution you've proposed, as it's the one you have suggested, and, yes, I can use more technical help.

What do you mean when you say "From the hotel editor in wp-admin..."

I tried making the post type "Restaurants" a child of the Parent Post "Stays" (which are the hotels,) and then went to one of the defined "parents," in this case a "Stay" aka "hotel,) and this is the result (imimage attached) I don't want to add all of that information there.

I simply want to be able to link to the child (on-premise restaurants) from the parent (stays aka hotels) with a text link. This box doesn't even have a place to enter the url of the restaurant which is ON MY SITE.

Also don't have any idea what the repeating fields error is. Thank you.

#537216

What do you mean when you say "From the hotel editor in wp-admin..."
I mean log in to your wp-admin area, then in the WordPress menu you will see "Stays". Click that, and you will see a list of all the Stays you have defined. Click the name of any Stay to enter the Stay editor.

I tried making the post type "Restaurants" a child of the Parent Post "Stays" (which are the hotels,) and then went to one of the defined "parents...I don't want to add all of that information there."
If you don't want to manage Restaurant information in the Stays post editing area, that's fine. There is another option for managing Restaurants. Go to Restaurants > Add New and create individual Restaurants here with all the appropriate data. After you save a Restaurant, you will then have the ability to select a parent Stay using a typeahead / select field in the Post Relationship panel.

I simply want to be able to link to the child (on-premise restaurants) from the parent (stays aka hotels) with a text link. This box doesn't even have a place to enter the url of the restaurant which is ON MY SITE.
The Toolset way to accomplish this is to first create your Stays and Restaurants post types. Select Stays as a parent post type of Restaurants. Then create some Stays and create some Restaurants (from Restaurants > Add New). As you create Restaurants, select a parent Stay for each one.

Then, when you want to show a list of associated Restaurants for each Stay, you will use a View. You will create a View of Restaurants, which are children of the current Stay. Then you can place this View on each Stay page using a Content Template or a View shortcode.

I have some information about querying and displaying child posts for you to review:
https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/

Let me know your thoughts here.

#538083
jim's-hotel-2.jpg

The attached will perhaps help to clarify what it is I am trying to do.

Please understand: Jim's Hotel has two restaurants on its premises. Those two restaurants are also open to the public.

Those two restaurants, therefore, have their own pages on my site.

I want to show a link to these two restaurants from the Jim's Hotel page.

There will be hundreds of hotels with the same requirement: to link to the restaurant pages of the restaurants that are on their premises.

That's all. That's all I want to do.

The attached image is a screenshot of a sidebar in a content template on a hotel page. I have added the "Jim's Hotel" title and the "On-Premises Dining at Jim's Hotel" to show you what I am trying to do.

Is it really so impossible? Would it behoove me to take advantage of Advanced Custom Fields in order to accomplish this?

Also, FYI: I can NOT use Layouts with my theme, which is a Genesis framework based theme. IT. DOES. NOT. WORK. WITH. GENESIS. Have been through this with support a number of times since Layouts was introduced, so please let's not go there.

My frustration level is through the roof. Looking forward to your replies.

#538127

Got the answer on the facebook Toolset Types Views Help group.

"If I've understood you correctly it's now sorted. You needed to display child posts inside the parent. I did this creating a view and selecting the option of "child of the post this view appears in" Then just select thefields you want to show.

hidden link

#538277

I'm glad you were able to get the information required, though I'm sorry that you had to reach out to an external resource to get the help you needed. If you need any additional help let me know.

#538324

No worries! Good learning experience, tons of good info from you. Thank you, Christian!

#538642

Very well, let's close this ticket.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.