Skip Navigation

[Resolved] link from a custom field in social media icons block

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

Problem:

I want to link social media icons in WordPress to different content based on each post's Toolset Custom Fields. When I insert the shortcodes in the link field of the Social Media Icons block, they only open an about:blank#blocked page.

Solution:

WordPress's Social Icons block doesn't support shortcodes in the link field. As an alternative, consider using Toolset's Social Share block, which allows more flexible linking based on custom fields.

Relevant Documentation:

https://toolset.com/block-item/social-share/

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.

This topic contains 1 reply, has 2 voices.

Last updated by Christopher Amirian 1 year ago.

Assisted by: Christopher Amirian.

Author
Posts
#2672429

I want to use the built in Social Media Icons block in WP in every post. I'd like the icons to link to different content, depending on the post. I add the links in Toolset Custom Fields in each post and that's the links I want the icons to link to. When I add the shortcodes for the relevant custom fields directly in the post template or use them as a link for an image, they display just fine. But when I add them in the link field on the relevant social media icons, the icons just open an about:blank#blocked page. How do I get the shortcodes to work in the link?

#2672483

Christopher Amirian
Supporter

Languages: English (English )

Screenshot 2023-12-11 at 10.49.15.png

Hi there,

I tested that and unfortunately, it seems the social icons block in WordPress does not allow a shortcode inside the LINK option and it does not convert the result to a real link.

I tested that in the clean installation below that you can log in:

hidden link

I created a custom field called social-link and assigned it to a page.

If you go to the test page that I created I used the Social Icon block and a simple shortcode block and I added a sample URL into the custom field item itself.

If you check the front end you will see that the shortcode is rendered correctly when using the Shortcode block, but it is not when you add the shortcode inside the Link option of the Social Icon block. I used this shortcode:

[types field="social-link" output="raw"][/types]

There is nothing we can do to force the default block of WordPress to accept shortcode inside the Link option.

Alternatively, you can use the Social Share block by Toolset:

https://toolset.com/block-item/social-share/

Thanks.

#2673379

That's a shame, but I guess nothing can be done. Thanks for investigating!