我不知道过滤器的确切顺序是什么the_content(); 还有,这是否足够早,但如果它对你不起作用,我相信可以安全地假设你认为短代码适用于晚代码是正确的。
从…起/wp-includes/shortcodes.php (第296行,wp 3.2.1)可以看出,短代码的自然解析如下:
add_filter(\'the_content\', \'do_shortcode\', 11); // AFTER wpautop()
 正在执行
do_shortcode 相反,当
the_posts 钩子运行应该确保足够早地执行它们。
the_posts 从数据库检索帖子后立即运行。以下应起作用:
add_filter(\'the_posts\', \'rutwick_shortcode_exec\');
function rutwick_shortcode_exec($posts) {
    $post_count = count($posts);
    for ($i = 0; $i < $post_count; ++$i) {
        do_shortcode($posts[$i]->post_content);
    }
    return $posts;
}
 降低优先级可能就足够了:
add_filter(\'the_content\', \'do_shortcode\', 9);
 值得注意的是,我没有测试上述内容,也不能保证什么都没有。此外,您可能会与
wpautop, 因为如果应用了上述代码,则短代码(所有短代码!)现在在过滤内容之前解析。
EDIT: 尽早运行您自己的替换函数可能会更安全(以下假设您的短代码被称为[下一步]):
function do_rutwick_shortcode($content) {
    $content = preg_replace(\'{\\[next\\]}\',\'<!--nextpage-->\',$content);
    return $content;
}
 并使用上述两种方法中的任何一种调用它(即将其挂接到
the_content 使用较低优先级编号或替换
do_shortcode(...) 具有
do_rutwick_shortcode(...) 在上面
for 循环)。如果您选择这样做,请使用
add_shortcode 变得多余。此外,如果你选择
the_posts 这个
preg_replace 可以直接在所述功能中运行,不需要两个,即:
$posts[$i]->post_content =
    preg_replace(\'{\\[next\\]}\',\'<!--nextpage-->\',$posts[$i]->post_content);
 将为您保存一个函数调用。