首页 > 解决方案 > Wordpress、save_post、post_status 并不是数据库中的内容

问题描述

add_action("save_post", [$this, "save"]);

function save($postId)
{
    $post = get_post($post_id);
    echo $post->post_status; // its "inherit" instead of "publish" !
    echo $post->post_status; // its "revision" instead of "draft" !
}

然后在数据库中有“ publish”,我得到get_post($post_id)->post_status=> ' inherit' !

或者在数据库中有“ draft”,我得到get_post($post_id)->post_status=> ' revision' !

为什么?我需要根据 post_status 做一些操作,我不能那样做

标签: wordpress

解决方案


推荐阅读