Skip Navigation

[Gelöst] Added rel=nofollow to link

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
How can I add nofollow attributes to Links created with Toolset ShortCodes?

Solution:
You can't, the ShortCode attributes do not allow it.

But, you can use Custom HTML and use the Tooslet Fields as the dynamic data, and add nofollow manually:

<a href="[types field='url'][/types]" rel="nofollow">Link title</a>
This support ticket is created vor 7 Jahren. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Dieses Thema enthält 10 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von jamesW-18 vor 7 Jahren.

Assistiert von: Beda.

Author
Artikel
#586154
CaptureA.JPG

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? versteckter 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.

#586217

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>
#586304

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!

#586999

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 🙂

#587150

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.

#587156

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.

#587158
Capture B.PNG
Capture A.PNG

Thanks for your patience with me.

Please see attached screenshots. Capture A is the code I am using, capture B is the output.

Thanks!

#587161

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!

#587162
Capture C.PNG

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.

#587165

[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)

#587168

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!