_acf_untrash_field_group_post_status()


WordPressの_acf_untrash_field_group_post_status()関数は、ゴミ箱からACFフィールドグループを復元する際に使用される内部関数です。この関数は、フィールドグループのステータスを「ゴミ箱」から「公開」に変更します。

構文

_acf_untrash_field_group_post_status( int $post_id );
  • $post_id(int) — 復元するフィールドグループの投稿ID。

例1: フィールドグループをゴミ箱から復元

特定のフィールドグループをゴミ箱から復元します。

_acf_untrash_field_group_post_status( get_the_ID() );

例2: カスタム投稿タイプのフィールドグループを復元

カスタム投稿タイプのフィールドグループを復元します。

_acf_untrash_field_group_post_status( get_post( 'custom-post-type-slug' )->ID );

例3: 複数のフィールドグループを一括で復元

複数のフィールドグループをゴミ箱から復元します。

$post_ids = array( 123, 456, 789 ); foreach( $post_ids as $post_id ) { _acf_untrash_field_group_post_status( $post_id ); }

例4: 特定の条件でフィールドグループを復元

特定の条件を満たすフィールドグループのみを復元します。

if ( get_post_status( get_the_ID() ) === 'trash' ) { _acf_untrash_field_group_post_status( get_the_ID() ); }

例5: フィールドグループの復元後にアクションを実行

フィールドグループを復元した後にカスタムアクションを実行します。

_acf_untrash_field_group_post_status( get_the_ID() ); do_action( 'after_untrash_field_group', get_the_ID() );

注意点

  • この関数は内部使用を目的としているため、直接使用する際は注意が必要です。
  • フィールドグループの復元前に、適切な権限とバックアップを取ることを推奨します。