Shortcodes with Attributes

Post Reply
User avatar

Topic Author
Kygo <>
Founder
Founder
Posts: 140
Joined: 26 Sep 2024, 21:31
Location: Romania
Has thanked: 1 time
Been thanked: 15 times
Contact:
    Windows 10 Edge
Dec 2024 27 13: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

Image
Post Reply