我们可以在post第一次发布时将值存储到POSTETA中。
function save_ispublished( $post_id ) {
if (defined(\'DOING_AUTOSAVE\') && DOING_AUTOSAVE)
return;
$published_once = get_post_meta( $post_id, \'is_published\', true );
// Check if \'is_published\' meta value is empty.
if ( ! empty( $published_once ) ) {
$published_once = \'yes\';
}
// store is_published value when first time published.
update_post_meta( $post_id, \'is_published\', $published_once );
}
add_action( \'save_post\', \'save_ispublished\' );
您可以通过获取元值来检查它。
$is_published = get_post_meta( $post_id, \'is_published\', true );
if( $is_published == \'yes\' ) {
/*
* Actions if post is already published atleast once.
*/
}
希望这有帮助!