カスタムフィールドの有無あるかないかの判定
- 公開日:
- 更新日:
- 文字数:276文字
<?php
$custom_fields = get_post_meta( $post->ID , 'field_name' , true );
if(empty( $custom_fields ) === false){ ?>
カスタムフィールドに値があるときの処理
<?php } else { ?>
カスタムフィールドがないときの処理
<?php } ?>
引用元
https://webmanab-html.com/tip/wordpress-custum-field-if/
