I have a website with a lot of
[mybutton]click here[/mybutton]
or
[mybutton]click there[/mybutton]
in editor. I need to add a function to create a href from this shortcodes. Closing of shortcode is a problem for me. How can i do it?
I have a website with a lot of
[mybutton]click here[/mybutton]
or
[mybutton]click there[/mybutton]
in editor. I need to add a function to create a href from this shortcodes. Closing of shortcode is a problem for me. How can i do it?
Share Improve this question asked Jun 21, 2019 at 13:57 Łukasz GręźlikowskiŁukasz Gręźlikowski 254 bronze badges2 Answers
Reset to default 3To change the functionality of a shortcode you must first remove_shortcode( 'shortcode_name' );
where shortcode name is the name of the shortcode. Add the shortcode back with your NEW function.
A simple example to follow what you might be needing:
remove_shortcode( 'mybutton' );
add_shortcode( 'mybutton', 'my_shortcode_function' );
my_shortcode_function( $atts, $content = "" ) {
return '<a href="http://example">' . $content . '</a>';
}
That is a short code not HTML you can put any Attribute there, if you want that function got to your page builder and insert a text editor and to html editor and create a button so you can put any attribute you want in it.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745380935a4625222.html
评论列表(0条)