WordPress.org

Ready to get started?Download WordPress

Forums

content_save_pre filter run twice? (5 posts)

  1. blueven
    Member
    Posted 4 years ago #

    The function which registered in content_save_pre filter will run twice when saving or publising post, why?

    code sample:

    function wp_a_little_test($content)
    {
        static $num;
        if ($num > 0) {
            exit('Yes, the function run twice!');
        }
        $num++;
        return $content;
    }
    add_filter('content_save_pre','wp_a_little_test');
  2. blueven
    Member
    Posted 4 years ago #

    Anybody know?

  3. dinoe
    Member
    Posted 4 years ago #

    I'm facing the same problem.
    Is there any solution available?

  4. DigiproveDevelopment
    Member
    Posted 4 years ago #

    Me too. I just got round it by keeping a counter as in the example above and ignoring everything after the first one. But why - I don't know.

  5. sjordan8
    Member
    Posted 3 years ago #

    I had this problem too..

    I got around it like this:

    add_filter('content_save_pre', 'foo');

    function foo($content) {

    //won't let it happen again
    remove_filter('content_save_pre', 'foo');

    return $content;
    }

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.