Please share the code from your plugin that is hooking into the_content.
Also show the URL that has the problem.
The ste with the issue: muitocurioso.org
This is a client site, on my test site there are no issues.
The plugin is Ad Inserter
https://ww.wp.xz.cn/plugins/ad-inserter/
the code around line 1420:
add_filter ('the_content', 'ai_content_hook', $plugin_priority);
https://plugins.trac.ww.wp.xz.cn/browser/ad-inserter/tags/2.5.0/ad-inserter.php
Actually from the log file it seems that the_content hook is called twice, however, the post output is not changed.
As a workaround I added the following code:
add_action ('pre_amp_render_post', 'ai_pre_amp_render_post');
function ai_pre_amp_render_post() {
add_filter ('the_content', 'ai_content_hook');
}
Now the_content hook is called 3 times more and the post content is processed.
However, this is only a temporary workaround.
If a plugin adds a the_content filter, then that’s all that should be required by the AMP plugin. The logic in the Ad Inserter plugin for adding this filter is hard to understand:
https://plugins.trac.ww.wp.xz.cn/browser/ad-inserter/tags/2.5.0/ad-inserter.php#L1419
I suggest contacting that plugin’s author.
I am the plugin author.
The problem is that this filter is called two times, however, the post content is not processed as returned by the filter processing in Ad Inserter.
It behaves like the filter hook from Ad Inserter is removed from the queue before the post gets written.
OK. I suggest trying to create a minimal test case to reproduce the problem.
For example, I just tried creating a little plugin that appends to the content a counter for the number of times the filter is called:
add_filter(
'the_content',
function ( $content ) {
static $call_count = 0;
$call_count++;
return $content . "<p>Called: $call_count</p>";
}
);
I only ever see $call_count as 1, so the AMP plugin is only applying filters for the_content once.
Problem solved.
Ad Inserter calls hooks with default priority 99999 so is it called last – to insert into content processed by other plugins.
It seems that this high priority causes the content not to be processed by Ad Inserter.
So I simply set priority to 10 and now it works as it should.
Thanks for the hint!
This helped me to figure out the reason.