$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>filters - Output content to the_content before a plugin does|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

filters - Output content to the_content before a plugin does

matteradmin10PV0评论

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....)

Post a comment

comment list (0)

  1. No comments so far