Hyperlink URL with meta box shortcode
- This topic has 7 replies, 2 voices, and was last updated 8 years, 3 months ago by
janek.
-
AuthorPosts
-
August 17, 2017 at 7:03 AM #6668
janek
ParticipantHi, I'm having trouble with with the URL meta box shortcode.
My idea is to enable authors to create a list of links to accompany a page or post however when I use the shortcode to display the URLs they do not display as a hyperlink, instead they are just listed as plain text.
The shortcode I'm using is
[rwmb_meta meta_key="url_1" ]
Is there a simple fix to enable hyperlinking?
August 17, 2017 at 8:33 AM #6669Truong Giang
ParticipantHi there,
Do you means https://metabox.io/ instead of https://metabox.io/?
You can use this code:
echo make_clickable( do_shortcode( '[rwmb_meta meta_key="url_1" ]' ) );Thank you.
August 17, 2017 at 8:44 AM #6670janek
ParticipantSorry my knowledge of coding is pretty bad.
Currently I have the shortcode sitting within a widget that appears on a sidebar on my site. If I add the code you supplied to the widget it will not work.
You can see an example of what I've achieved within the sidebar/widget with the original shortcode.
http://7c79b000.ngrok.io/academy-sports/tennis/Sorry for the slow connection, just a temp site at the moment.
If I use your code, where would I need to put it to affect the shortcode within the widget. Or is there another approach I can take to achieve the same result.
August 17, 2017 at 10:45 AM #6673Truong Giang
ParticipantHi,
You can insert this to widget:
<a href="[rwmb_meta meta_key="url_1" ]">[rwmb_meta meta_key="url_1" ]</a>Thank you.
August 17, 2017 at 10:52 AM #6674janek
ParticipantHi Truong,
That code within the widget seems to just turn the URLS to
http://swas.dev/academy-sports/tennis/%5Brwmb_meta%20meta_key=
instead of http://www.google.com for example.August 18, 2017 at 8:22 AM #6684Truong Giang
ParticipantOh so sorry, I have a mistake. Please try the code below:
<a href='[rwmb_meta meta_key="url_1"]'>[rwmb_meta meta_key="url_1"]</a>And you should switch the editor to text mode instead of visual mode.
August 18, 2017 at 9:18 AM #6687janek
ParticipantNo worries. Still having problems with this.
Using the code above both links (google.com and googlemaps.com) forward to
http://www.googlemaps.com%3C/li%3E%3C/ul%3E
Complete code for the widget looks like:
<xmp>
<h4>Application and Information Forms</h4>
[rwmb_meta meta_key="applications_forms" type="file-advanced"]
<h4>Links</h4>
[rwmb_meta meta_key="url_1"]</xmp>August 18, 2017 at 9:44 AM #6689janek
ParticipantDisregard the xmp. Trying to figure out how to display the code without it actually running the code.
Should be able to see the code I'm using via the following link
https://jsfiddle.net/f9et2en3/ -
AuthorPosts
- The topic ‘Hyperlink URL with meta box shortcode’ is closed to new replies.