I have a button shortcode on my website which I will be using in all of my posts.
What I want is, If I modified the button value the changes should be applied to all the button on the website.So that I don’t have to modify each and every post.
I want to change the buttons Caption, Link and maybe rel
For example:
[button rel="[btn-rel]" url="[btn-url]"] [btn-cap] [/button]
I googled the problem and added following code to Function.php to change the button caption.
function btn_cap() {
return 'More Freebies!';
}
add_shortcode('btn-cap', 'btn_cap');
and added the Shortcode to the button shortcode like this:
[button][btn-cap][/button]
Which didn’t worked out 🙁 The caption of the button is “[btn-cap]” not “More freebies”
I really want this thing to work as it will save me alot of time and work.
Thanks in advance…
You cannot use shortcodes as variables/placeholders as in your example. You can however write your own button shortcode with the default values you require.
Add the following to functions.php
Uses
Output
Hopefully this code will get you started.