Skip Navigation

[Resolved] LINK type custom field

This support ticket is created 2 years, 9 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 14 replies, has 2 voices.

Last updated by luisA-5 2 years, 9 months ago.

Assisted by: Minesh.

Author
Posts
#2120843

I need a LINK type custom field. As far as I know, only an URL type is available in Toolset. I don´t understand why such a simple thing is not included in a paid plugin like this one.

Imagine a website about books, with a “book” custom post type. I would like to be able to add links to a simple “More about this book” section. It does not matter whether they are links to post or pages within the same website or external links. Just links, where I could set not only the URLs but also the anchor texts and the labels individually when editing each “book” custom post. As simple as that.

I know the URL field allows me to choose the anchor text (named URL link label by Toolset in Field Settings), but that is a fixed text in the template which would apply to each and every “book” custom post.

I don´t want a “Click here” or “Follow this link” generic anchor text all over the place, I need that text to be pulled dynamically from the custom field (as the URL itself is). That way I could let the users of my website know what the links are about, instead of having them guess from ugly URLs (not to mention if some of the links were affiliate links).

I´m talking about a very simple an basic feature which would allow me to show links like this:

More about this book:
- Read our review about this book
- Read somebody else´s review
- This book in Wikipedia
- Buy this book in Amazon
- Buy this book somewhere else
- ...

Please, don´t tell me this is not possible with Toolset.

#2120849

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

What if you try to use the anchor text to build a link:

<a href="[add-your-types-url-field-shortcode]"> Replace with Types shortcode or any other text </a>
#2120853

I need it to be done in an user friendly manner (like in ACF, for instance), so anybody without HTML knowledge at all can edit the custom post and add a simple custom link. Well, and not even not just one, but as many as needed.

#2120887

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You can add as many Anchor tags as you want. I'm not sure yet where exactly you want to display the link.

Are you using blocks to build your content template or you are using classic views?

If you can tell me where exactly you want to display the links and problem URL then once I review it I will able to guide you in the right direction and share all the possible ways to add the links.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2120917

The website is in a very early state of development, and it is just a local site in my computer, created with DesktopServer.

But really, I´m talking about a very simple and general application, it shouldn´t depend on where I want to display the links. I should be able to display them anywhere on the custom post.

Simplest situation: a container, and then inside it a heading ("More about this book:", in the example) and a list of links under it.

The amount of links has to be variable (some posts might not have any link at all), and the urls and anchor texts need to be editable in the appropriate repeater field when editing each post.

By the way, I´m using blocks for the content template.

#2120923

I´ve just replied selecting "This reply doesn't contain any private information and can be visible to all forum members" but I can´t see my reply

#2121001

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

If you want to add a dynamic label then you should try to add Single field block and in the "URL Link label" field you can add the Types shortcode that hold the dynamic label for the link. Please check the following screenshot:
=> hidden link

If you are using repeating field, then you should try to use the repeating field block.
=> https://toolset.com/block-item/repeating-field/

If you want to display custom links then you will have to use either "Fields and Text" block and add your custom fields as required using anchor tags.

#2121209

Ok, I managed to do it via a repeatable group with 2 custom fields, one for the URL and another for the anchor text. Then in the template I use a view for the repeatable group, I select the URL field and, in its Field Settings, I use "[types field='anchor-text'][/types]" as the URL link label, following the indications in your screenshot.

It works, but the problem now is that the order displayed on that list is not determined by the order of the fields I expect when I sort them by drag and drop, I mean when I change the position of the various elements of the repeatable group when editing each post. I guess the order is determined by the time each element was added.

Is there any way to change this behaviour, so I can display those links in the order I decide by sorting them out when creating or editing each post?

#2121899

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You created repeating field or repeating field group? Can you please share screenshot how exactly you configured of post edit screen?

Please share screenshot of how you configured on backend and how you are displaying on frontend on content template and how actually it displayed on frontend.

#2122315
Captura de pantalla 2021-07-22 a las 14.11.55.png
Captura de pantalla 2021-07-22 a las 14.17.28.png
Captura de pantalla 2021-07-22 a las 14.12.16.png
Captura de pantalla 2021-07-22 a las 14.13.34.png

Ok, here we go. Here are screenshots for:
- The custom fields I created
- The content template
- The custom post edit screen
- The custom post as displayed on the front end
Please note that the order of the links on the post as displayed on the front end is not the order I specified by sorting them on the post edit screen. This is what I asked you about yesterday.

The reason why I used a repeater group instead of repeater fields is because that way each link URL is perfectly related to its link text, and I can for example drag and sort both at the same time. If I used repeater fields I would have needed to create two repeater fields, one for the link URLs and one for the link texts. The correspondence beetween both would be screwed up if I sorted one set in a different way than the other, and I would need to keep track of the order of both, to make sure that the correspondences are correct.

#2122361

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok - I see you are using the repeating field group.

So, here are the steps you should follow to display the repeating field group correctly.
- https://toolset.com/course-lesson/creating-and-displaying-repeatable-field-groups/#displaying-repeatable-field-groups

And here are the steps to display the repeating field group items in custom order:
- https://toolset.com/course-lesson/creating-and-displaying-repeatable-field-groups/#displaying-repeatable-field-groups-in-custom-order

To list items in a custom order, select the main View block and in the right sidebar, expand the Ordering Settings section. In the Sort By dropdown, select the Field – toolset-post-sortorder option. Also, select the order to be Ascending.

#2122385

Thank you, I got it.
Just curious, and just in case... Is there any way to use repeating fields for this purpose without the drawbacks I mentioned?

#2122429

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

When you want to have group of fields like (link+caption) in such cases you should use the repeating field group and thats the right choice.

If you have any issue in future, you are welcome to open a new ticket and we are eager to help you out.

#2122947

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You are welcome to mark resolve this ticket 🙂

#2123133

I´m marking this as resolved. Thank you!

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