Tell us what you are trying to do? Add rel=nofollow to links
Is there any documentation that you are following? No.
Is there a similar example that we can see? No.
What is the link to your site? hidden link
I created a post field group which includes a URL field (see screen shot). I then add the field into the Products template (I am using WooCommerce). What I would like to do is have rel=nofollow added to the URL globally for this field.
It cannot be done in the GUI.
But you can use a Custom Syntax and thru insert your ShortCode for this field in a Content Template applied to your posts.
This will ensure that the setting is global on this post type / field.
The Field should be inserted like this, in the case you want to add a rel attribute:
<a href="[types field='toolset-url-field' output='raw'][/types]" rel="nofollow">Link title</a>
Thanks. My understanding is I will need to create a shortcode. I have created this:
function deal_link_nofollow(){
return '<a href="[types field='promotion-details' output='raw'][/types]" rel="nofollow">Link title</a>';
}
add_shortcode('deal_link', 'deal_link_nofollow');
But when I use the shortcode [deal_link] nothing is output. Plus I receive a "syntax error, unexpected 'promotion' (T_STRING)" when saving the shortcode.
Thanks!
Why?
You can use the code exactly as I passed it to you, as example in a Content Template.
If you want a more handy single ShortCode for this, you cannot return enter ShortCodes.
ShortCodes need to be executed, by do_shortcode().
What you can do is use PHP WordPress or Types API and call that field in a $variable.
Later, use that $variable in your Custom ShortCode.
https://toolset.com/documentation/customizing-sites-using-php/functions/
https://developer.wordpress.org/reference/functions/get_post_meta/
But as said, you might be better served by just using that syntax anywhere you want to have the Link used like that 🙂
Thanks for your reply. The code you provided is:
<a href="[types field='toolset-url-field' output='raw'][/types]" rel="nofollow">Link title</a>
I tried to use:
<a href="[types field="promotion-link" output='raw'][/types]" rel="nofollow">Link title</a>
And
<a href="[types field='promotion-link' output='raw'][/types]" rel="nofollow">Link title</a>
Both of which just output the code as it appears above.
I also tried:
Which also didn't work. I am placing the code when editing the Template for Products in the Edit Visual Editor Cell.
Any assistance you can provide is appreciated. Thanks.
Yes, that does not work.
As I illustrated we construct a link.
That is done with HTML:
title
We populate it with some dynamic value:
[types field='toolset-url-field' output='raw'][/types]
The no rel="" is not even handled by Toolset here, It is simple HTML.
What do you mean by "it does not work"?
I do see the HTML in the page's source when I use my code.
Thanks for your patience with me.
Please see attached screenshots. Capture A is the code I am using, capture B is the output.
Thanks!
Please use the HTML editor, not the Visual editor, when you insert HTML in any WYSIWYG in WordPress.
It's at the top right of the editor, a small "HTML" tab.
Thank you!
Thank you so much! That works, goofy mistake on my part.
However, what I really want is a button such as this:
[types field='promotion-link' title='Book Now!' target='_blank' class='button' style='margin-top:10px;'][/types]
However plugging this in:
<a href="[types field='promotion-link' title='Book Now!' target='_blank' class='button' style='margin-top:10px;'][/types]" rel="nofollow">Link title</a>
Results in the output in the attached screen shot.
Is there anyway to do this?
Thanks.
[types field='promotion-link' title='Book Now!' target='_blank' class='button' style='margin-top:10px;'][/types]
Link title
You cannot add a Title in a ShortCode in a HTML attribute.
Please follow my syntax example here:
https://toolset.com/forums/topic/added-relnofollow-to-link/#post-586217
We only use ShortCode to populate single things, not all together. If we do that all in one we do not need HTML and could do it with one ShortCode.
But ShortCode is never as alborated as HTML.
Hence here we use HTML, and populate the HTMNL with ShortCode.
So your HTML must be just the same as before, the short code too, just use a Button HTML instead of Links, or populate your Custom HTML button with the right link.
Or just pass a class to the link in the HTML (not in our shortcode but in your HTML)
Thank you so much! You are incredible. I appreciate you being patient and understanding with me. Great support! Thank you and have a great day!