Creating a self-closing shortcode
The simplest shortcode is the self-closing one. We’re going to create a simple link to our Twitter account, and then add it in a blog post.
All the code goes in functions.php, which is located in /wp-content/themes/your-theme/. If you don’t have one, just create it and put the code in it.
<?php function button_shortcode() { return 'Follow me on Twitter!"'; } add_shortcode('button', 'button_shortcode'); ?>
How to Usage:
[button]
Simply using the the add_shortcode()
function, we can link any php function to our shortcode. In this simple example, all we do is returning a link to our Twitter account, but let’s take this a step further and add some parameters.
Hey there! Would you mind if I share your blog with my zynga group?
There’s a lot of folks that I think would
really appreciate your content. Please let me know.
Thank you
LikeLike
This information is worth everyone’s attention.
When can I find out more?
LikeLike
Yes sure… 🙂
Open this : https://codex.wordpress.org/Function_Reference/add_shortcode
LikeLike
Hi! I’ve been following your weblog for a while now and finally got the bravery to go ahead
and give you a shout out from Lubbock Tx! Just wanted to say keep up the great work!
LikeLike
Thanks a lot and always most welcome 2 u 🙂
LikeLike
Touche. Solid arguments. Keep up the amazing effort.
LikeLike
Thanks 🙂
LikeLike
If you are going for most excellent contents like me, simply visit this site every day for the reason that it provides feature contents, thanks
LikeLike
Thanks 🙂
LikeLike