Shortcodes with Attributes

Post Reply
User avatar
Kygo
Founder
Founder
Posts: 334
Joined: 26 Sep 2024, 22:31
Contact:
Dec 2024 27 14:49

Shortcodes with Attributes

Post by Kygo

To create a shortcode for links, we need to include the attribute information as well as the anchor text for the link itself. We can do this by placing this function in your theme’s file:hreffunctions.php
Please Login or Register to see this code Then, when creating a post, emulate the following format to include any links you wish:

[link href="https://perishablepress.com/"]Perishable Press[/link]

..which will output the following code:

<a href="https://perishablepress.com/">Perishable Press</a>

When the attribute is removed from the shortcode, the default URL will be used. You may specify the default URL in the third line of the funtion (see comment).href
Post Reply