php - How can i create a function tag in my plugin

I want to know how what function or hook i can useto create a php function that executes as tagslike this[block] c

I want to know how what function or hook i can use to create a php function that executes as tags like this
[block] content to be blocked[/block]
my function will start with [start] afftected content goes here [/end] anything inside the start tag and the end tag will be affected by my function, it could a simply unset or hide or exclude kind of function, please i need to include this in my plugin, any suggestions.

I want to know how what function or hook i can use to create a php function that executes as tags like this
[block] content to be blocked[/block]
my function will start with [start] afftected content goes here [/end] anything inside the start tag and the end tag will be affected by my function, it could a simply unset or hide or exclude kind of function, please i need to include this in my plugin, any suggestions.

Share Improve this question asked Jun 10, 2020 at 19:40 pandglobalpandglobal 431 silver badge9 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You are looking for Enclosing Shortcode. Here is an example of how you can achieve this.

function example_shortcode($atts = [], $content = null)
{
    // do something to $content

    // run shortcode parser recursively
    $content = do_shortcode($content);

    // always return
    return $content;
}
add_shortcode('example', 'example_shortcode');

Now you can use it like [example] Here is my content [/example]

Read more about add_shortcode() here

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742358843a4428979.html

相关推荐

  • php - How can i create a function tag in my plugin

    I want to know how what function or hook i can useto create a php function that executes as tagslike this[block] c

    1天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

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

关注微信