Add shortcode with open close function

I have a website with a lot of [mybutton]click here[mybutton] or[mybutton]click there[mybutton]in editor. I need to a

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 badges
Add a comment  | 

2 Answers 2

Reset to default 3

To 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

相关推荐

  • Add shortcode with open close function

    I have a website with a lot of [mybutton]click here[mybutton] or[mybutton]click there[mybutton]in editor. I need to a

    9小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信