Skip Navigation

[Resolved] Using custom field data from a specific post to create a mailto link in a menu

This thread is resolved. Here is a description of the problem and solution.

Problem:
The user would like to implement site options using a custom post type and a post. He would like to use its custom fields as options and render their values, and links, in menus.

Solution:
Hello and thank you for contacting the Toolset support.

I am not familiar with Elementor Navigation Menus, but if you are talking about a regular WordPress menu, I'll suggest using this 3rd party plugin and put the shortcode in the desired menus:
https://wordpress.org/plugins/shortcode-in-menus/

Or you can use the shortcode in a custom code that is hooked to wp_nav_menu_items or wp_nav_menu_{$menu->slug}_items with the do_shortcode function

Relevant Documentation:

This support ticket is created 3 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
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: Africa/Casablanca (GMT+01:00)

This topic contains 3 replies, has 2 voices.

Last updated by barryG-4 3 years, 9 months ago.

Assisted by: Jamal.

Author
Posts
#1943961
toolset.jpg

Tell us what you are trying to do?
I have a custom post type called Site Details. I have phone number and email address custom fields assigned to Site Details. I created one Site Details post as a way of storing site wide details for a business. The idea is that I add shortcuts throughout the site that use the phone numbers and email addresses in that post to display the data throughout the site. So if a client changes the phone number, they do it once in that post and the changes are reflected everywhere. I'm not sure how other people do that but that's the only way I can think of doing it at the moment. Please tell me if there's an easier way using Toolset.

So I have the fields filled in and using for example: [types field='email-address' post_id='179'][/types] I can display the data in a button or a text field successfully. I can't seem to do that in a menu or even in an Elementor Navigation Menu set to custom, even though there are options to use shortcodes and it's the shortcodes options inside Elementor that work everywhere else. I've tried all sorts of combinations of things but I just can't get the clickable 'email' word in the menu to correctly pull the data from the post's custom field.

Is there a way of doing this? I would have thought many businesses would want a phone number in a menu and if I can't get it done dynamically I'd be surprised. I would have thought it's a common thing to want to do.

Is there any documentation that you are following? No

Is there a similar example that we can see? Click the hamburger on the right hand side of the page under the telephone icon (another test menu) and click the 'phone' menu item once the hamburger has been clicked.

hidden link

#1943991

If you click the phone number icon on the right in the link below (a site I finished last week) you'll be able to click on the UK, INT and WhatsApp links to dial the numbers and bring up a WhatsApp page but these only work because I entered tel:07967555555 for example in a standard WP menu custom link and this is no good to my client who will need to ask me to change the phone number each time manually. I am hoping a dynamic solution can be found from using Toolset custom field data.

hidden link

#1945499

Hello and thank you for contacting the Toolset support.

I am not familiar with Elementor Navigation Menus, but if you are talking about a regular WordPress menu, I'll suggest using this 3rd party plugin and put the shortcode in the desired menus:
https://wordpress.org/plugins/shortcode-in-menus/

Or you can use the shortcode in a custom code that is hooked to wp_nav_menu_items or wp_nav_menu_{$menu->slug}_items with the do_shortcode function
- https://developer.wordpress.org/reference/hooks/wp_nav_menu_items/
- https://developer.wordpress.org/reference/hooks/ wp_nav_menu_menu-slug_items/
- https://developer.wordpress.org/reference/functions/do_shortcode/

I hope this helps. Let me know if you have any questions.

#1945663

My issue is resolved now. Thank you!