在add_filter()之前运行快速代码;
因此,我在WordPress网站上有短码[MY_EXAMPLE_SHORTCODE]。
add_shortcode('my_example_shortcode','shortcode_for_project');
我想优先考虑短代码 add_filter('the_content','my_example');
如果在页面上找不到快捷代码,则我希望应用上面的代码。
我已经尝试过:
if (shortcode_for_project) {
echo do_shortcode('[my_example_shortcode]');
}
else
{
add_filter('the_content', 'my_example');
}
假设我有一个页面:
商业智能
lorem ipsum dolor sit amet,consectetur adipiscing elit。 Donec Sem 麦格纳(Magna
那我想要 add_filter('the_content','my_example');
要启用,
但是如果
商业智能
[my_example_shortcode]
lorem ipsum dolor sit amet,consectetur adipiscing elit。 Donec Sem 麦格纳(Magna
那我想要 add_filter('the_content','my_example');
被禁用
So I have the shortcode [my_example_shortcode] on my WordPress site.
add_shortcode( 'my_example_shortcode', 'shortcode_for_project' );
I want to prioritise the shortcode beforeadd_filter('the_content', 'my_example');
If the shortcode is not found on the page then I want the the code above to be applied.
I have already tried:
if (shortcode_for_project) {
echo do_shortcode('[my_example_shortcode]');
}
else
{
add_filter('the_content', 'my_example');
}
Let's say I have a page:
Business Intelligence
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sem
magna, maximus eget odio vel, dictum ultrices nunc.
Then I wantadd_filter('the_content', 'my_example');
to be enabled
But if
Business Intelligence
[my_example_shortcode]
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sem
magna, maximus eget odio vel, dictum ultrices nunc.
Then I wantadd_filter('the_content', 'my_example');
to be disabled
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我了解问题,这是您可以做到这一点的一种方法:
If I understand the problem here is one way you can do this: