_update_posts_count_on_delete

函式
_update_posts_count_on_delete ( $post_id )

_update_posts_count_on_delete: 當一個文章被刪除時,這個函式更新特定術語的文章計數: 當文章被新增、刪除或修改時,它被用來確保一個術語的文章數是準確的。

處理程式,當一個文章被刪除時,更新當前網站的文章數。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function _update_posts_count_on_delete( $post_id ) {
$post = get_post( $post_id );
if ( ! $post || 'publish' !== $post->post_status || 'post' !== $post->post_type ) {
return;
}
update_posts_count();
}
function _update_posts_count_on_delete( $post_id ) { $post = get_post( $post_id ); if ( ! $post || 'publish' !== $post->post_status || 'post' !== $post->post_type ) { return; } update_posts_count(); }
function _update_posts_count_on_delete( $post_id ) {
	$post = get_post( $post_id );

	if ( ! $post || 'publish' !== $post->post_status || 'post' !== $post->post_type ) {
		return;
	}

	update_posts_count();
}

常見問題

FAQs
檢視更多 >