フォームのユーザー入力から収集されたページにカスタム フィールドがあります。挿入されるたびに 1 つだけ (customfield1
とcustomfield2
) が挿入されます。またはが空div
の場合、全体 (class="customfield")を非表示にする方法がわかりません。別のクラスまたは ID に変更できません。customfield1
customfield2
customfield
どうもありがとうございました!
<div class="customfield">
<h4>Custom field title 1</h4>
<?php if( get_post_meta($post->ID, "customfield1", true) ): ?>
<?php echo get_post_meta($post->ID, "customfield1", true); ?>
<?php endif; ?>
</div>
<div class="customfield">
<h4>Custom field title 2</h4>
<?php if( get_post_meta($post->ID, "customfield2", true) ): ?>
<?php echo get_post_meta($post->ID, "customfield2", true); ?>
<?php endif; ?>
</div>