In my plugin I'm using


for filtering blog data before it gets saved in the database.

However this hook makes post-new.php to load latest post's data, like permalink, slug, author.

enter image description here

enter image description here

How to get rid of this bug?


I'm using Wordpress 4.4.13.

  • 5
    Please post your code. It's not possible to debug the issue without knowing what you are doing behind the scene.
    – Johansson
    Dec 15, 2017 at 9:21
  • if you still need an answer please post your code.
    – inarilo
    Dec 18, 2017 at 21:23

2 Answers 2


Not sure what must be causing this. Try replicating your entire filter hook with function in this format:

function filter_handler( $data ) {
   // do something with the post data
   return $data;

add_filter( 'wp_insert_post_data', 'filter_handler', '10', 1);

Let me know if something happens.

  • does it get fixed when you remove the filter hook?
    – Sid
    Dec 11, 2017 at 10:28
  • Yeah it does. And that's what's strange
    – Ognj3n
    Dec 11, 2017 at 10:30
  • Really strange!!! Could you provide the entire function? Also, try clearing the code inside your filter_blog_post_data function and see what happens. Just keep the return statement
    – Sid
    Dec 11, 2017 at 10:34
  • This is the part of my plugin's __construct: add_filter('wp_insert_post_data','filter_blog_post_data',10,1); and this is the filter_blog_post_data function: public function filter_blog_post_data($data){ return $data; }
    – Ognj3n
    Dec 11, 2017 at 10:47
  • the weirdest thing happening as the code is throwing a fatal error when i add add_filter('wp_insert_post_data','filter_blog_post_data',10,‌1); and works fine when i add add_filter('wp_insert_post_data','filter_blog_post_data'); Can you please try this.
    – Sid
    Dec 11, 2017 at 13:02

The key is what's inside filter_blog_post_data. Returned array from this filter is also applying to your new, not saved yet post as well.

function wpse_288685_filter_data( $data, $postarray ){

    $data['post_name'] = 'foo-bar';

    return $data;

add_filter('wp_insert_post_data', 'wpse_288685_filter_data', 10, 2);

This function will set post slug to foo-bar even when your are on post-new.php page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.