admin管理员组文章数量:1414628
My function only affects the Page content and not the page content from the posts in page plugin which I call with a shortcode in the page.
My plugin function
add_filter('the_content', 'modify_tables', 10, 1);
function modify_tables($content) {
//modifications...
return $content;
} // function modify_tables
My template code to ouput page
while (have_posts()) : the_post();
the_content();
endwhile;
My function only affects the Page content and not the page content from the posts in page plugin which I call with a shortcode in the page.
My plugin function
add_filter('the_content', 'modify_tables', 10, 1);
function modify_tables($content) {
//modifications...
return $content;
} // function modify_tables
My template code to ouput page
while (have_posts()) : the_post();
the_content();
endwhile;
Share
Improve this question
edited Nov 25, 2016 at 13:20
cjbj
15k16 gold badges42 silver badges89 bronze badges
asked Nov 25, 2016 at 11:30
jxwdjxwd
312 bronze badges
1
- How does the page plugin output its content? This is probably something you will need to ask of whomever wrote that plugin. – Milo Commented Nov 25, 2016 at 11:37
1 Answer
Reset to default 2Unmodified do_shortcode
is effectively a filter on the_content
with priority 11. Your filter has priority 10. So it runs before the shortcode is evaluated and it won't affect the post you put inside your page with a shortcode.
Now, you would think that the filter should also be triggered when the post inside the page is retrieved. This, however, is not necessarily true. The filter is only triggered when the content is retrieved with the_content
, not with get_the_content
.
Depending on what your modifications are, you may get the desired result if you set the priority on your filter to 99 or so, forcing the shortcode to be evaluated before the filter is applied.
本文标签: plugin developmentFilter on thecontent ignores shortcodes
版权声明:本文标题:plugin development - Filter on the_content ignores shortcodes 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745179040a2646379.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论