filters - Output content to the_content before a plugin does

admin2025-06-03  4

I'm using a plugin that appends to the_content() at a priority of 100. I want to place some content after the main content but before this plugin outputs. I assumed if I use a priority less than 100 that it will come before the plugin, but the plugin is always outputting before my extra content.

My code looks like this

add_filter('the_content', 'my_single_post_extra', 10);
function my_single_post_extra($content) {
    if(is_singular('post')) {
        $content = $content . '<p>Extra content</p>';
    }
    return $content;
}

The plugin is appending like follows:

add_filter('the_content', 'fbcommentbox', 100);
function fbcommentbox($content) {
    $content .= '<p>plugin content here</p>';
    return $content;
}

I was under the impression that by using a lower priority than a plugin, that I could get my content to output before its content. Is that not correct? How would I fix this issue?

I'm using a plugin that appends to the_content() at a priority of 100. I want to place some content after the main content but before this plugin outputs. I assumed if I use a priority less than 100 that it will come before the plugin, but the plugin is always outputting before my extra content.

My code looks like this

add_filter('the_content', 'my_single_post_extra', 10);
function my_single_post_extra($content) {
    if(is_singular('post')) {
        $content = $content . '<p>Extra content</p>';
    }
    return $content;
}

The plugin is appending like follows:

add_filter('the_content', 'fbcommentbox', 100);
function fbcommentbox($content) {
    $content .= '<p>plugin content here</p>';
    return $content;
}

I was under the impression that by using a lower priority than a plugin, that I could get my content to output before its content. Is that not correct? How would I fix this issue?

Share Improve this question asked Apr 1, 2017 at 5:58 tommyftommyf 4051 gold badge6 silver badges17 bronze badges 3
  • 2 sorry but what is actually the issue? It sound lie you do not fully understand how the plugin work and except for suggesting doing some more debuggin i am not sure what anyone will be able to say about it.... maybe some other filter changes the content even before that filter, or th plugin remove all other filters on the_content.... there are several options that may explain what you see – Mark Kaplun Commented Apr 1, 2017 at 6:16
  • Thanks, you answered my question. I outputted $wp_filter for the the_content hook and was able to see what was being output at the same time. You could put this as an answer as it may help someone else. – tommyf Commented Apr 1, 2017 at 7:48
  • since it is kinda low quality question, probably better to just delete it – Mark Kaplun Commented Apr 1, 2017 at 8:03
Add a comment  | 

1 Answer 1

Reset to default 0

It appears that Mark Kaplan's comment led the OP to the proper solution.

But it would be nice for the OP to post his solution as the correct answer, to help others that might have a similar problem.

(Spelunking unanswered questions....)

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748926151a314877.html

最新回复(0)