filters - How to use do_shortcode_tag to modify the output of a shortcode?

I would like to add shortcodes whose content gets processed by plugins before it gets displayed in the page.In particula

I would like to add shortcodes whose content gets processed by plugins before it gets displayed in the page.

In particular, I have a plugin which processes content between two $ signs to produce math formulas and graphs. A simple shortcode is

add_shortcode( 'test', 'test_sc' );
function test_sc( $atts ){ return "$\frac{15}{5} = 3$"; }

By writing $\frac{15}{5} = 3$ in a page this gets displayed

By writing [test] in a page this gets displayed $\frac{15}{5} = 3$

WordPress does a few things before the content from a page or post gets displayed on the site. For instance, it processes HTML paragraph (p) tags, it runs shortcodes and even sends the content to the theme and any plugins so they can do their thing to the content and include their bits.

I heard that using do_shortcode_tag (reference) it is possibile to do full content processing, but how to do that?

I would like to add shortcodes whose content gets processed by plugins before it gets displayed in the page.

In particular, I have a plugin which processes content between two $ signs to produce math formulas and graphs. A simple shortcode is

add_shortcode( 'test', 'test_sc' );
function test_sc( $atts ){ return "$\frac{15}{5} = 3$"; }

By writing $\frac{15}{5} = 3$ in a page this gets displayed

By writing [test] in a page this gets displayed $\frac{15}{5} = 3$

WordPress does a few things before the content from a page or post gets displayed on the site. For instance, it processes HTML paragraph (p) tags, it runs shortcodes and even sends the content to the theme and any plugins so they can do their thing to the content and include their bits.

I heard that using do_shortcode_tag (reference) it is possibile to do full content processing, but how to do that?

Share Improve this question asked Sep 29, 2019 at 20:09 sound wavesound wave 2151 gold badge3 silver badges15 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

You have a LaTex plugin? It probably filters "the_content". Try

return apply_filters( 'the_content', '$\frac{15}{5} = 3$' );

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

相关推荐

  • filters - How to use do_shortcode_tag to modify the output of a shortcode?

    I would like to add shortcodes whose content gets processed by plugins before it gets displayed in the page.In particula

    12小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

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

关注微信