开发者

How to identify a post is NEW or we are editing an existing one?

How do we identify that we are on a NEW Post page or editing an existing one from within the code.

I checked with $post->ID it returns POST ID in case of new Post also.

开发者_StackOverflow社区

Please suggest a solution.

Thanks in advance.


is it possible to use add_action such as:

function editing_flag(){
     //set a flag to the post being edited
}
add_action('edit_post','editing_flag');

then in a single.php, you check if the flag is set like:

if(flag){
    echo 'the post is being edited';
}

but remeber to unflag it when you are done editing. this is just an idea

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜