This support ticket is created hace 6 años, 4 meses. 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.
Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.
I have created a custom field called 'afepi-website' which is linked to a custom post type called 'member'.
I am building the theme in standard php files.
In the php file I want to output the link onto all single pages. I can do that, but I want the url that is entered into the field to provide the content of the href attribute on the anchor tag, while the clickable link on the website front end should simply read 'click here for website'.
But all I can get it to do is to output the raw url on the front end.
Hello. Thank you for contacting the Toolset support.
Well - do you mean that you want to display text "'click here for website' as anchor tag and when user click on that user should be redirected on the URL which is stored inside as custom field value. If Yes:
$url = types_render_field("afepi-website", array('ourtpt'=>'raw'));
if(!empty($url)){
echo '<a href='".$url."'> Click here for website </a>';
}
Oh wow thank you, let me give this a go and get back to you. And if I wanted to have an icon instead of "click here for website" from the built in WordPress icons, could I do that too in Toolset?
upps. could you please share problem URL and access details and tell me to which file you have added the code.
*** 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 would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).
I have set the next reply to private which means only you and I have access to it.
Okay I am pasting in here the full code so that you can take a look. It is definitely something in this code that is breaking the site, as when I remove it, the site works fine.
I need to put this in a shortcode in order for it to work in a theme. I think there must be a small piece of syntax that is breaking it, and hopefully you can see this here:
// Shortcode for member profile field: afepi-website
add_shortcode( 'afepi_website', 'afepi_website' );
function afepi_website() {
// The content of the shortcode to be output
$url = types_render_field("afepi-website", array('output'=>'raw'));
if(!empty($url)) {
return '<a href='".$url."'> Click here for website </a>';
}
}
Thanks again for your time, and very best wishes,
Andrew.
Well - indeed, there was a issue with quotes with the line of code you return.
Could you please try following code:
add_shortcode( 'afepi_website', 'afepi_website' );
function afepi_website() {
// The content of the shortcode to be output
$url = types_render_field("afepi-website", array('output'=>'raw'));
if(!empty($url)) {
return '<a href="'.$url.'"> Click here for website </a>';
}
}
It works beautifully. I'm trying to get everything to work in shortcodes which I can paste into Elementor, as right now there is no direct integration. And this is a treat, thank you!
Do you have any idea on when that integration will come? Tons of us are really looking forward to that moment.