1
<?php if(have_rows('team_members')): ?>
<?php while(have_rows('team_members')): the_row(); ?>
<div class="team-member-section">
<div class="container">
<?php if(get_row_layout() == 'team_members'): ?>
<section class="team-member-section">
<?php
$team_title = get_sub_field('team_title');
$team_member = get_sub_field('team_member');
$description = get_sub_field('description');
?>
<div class="team-title">
<?php echo $team_title; ?>
</div>
<?php if($team_member): ?>
<?php if (get_field('has_description') == 'yes') : ?>
<?php echo 'has_description'; ?>
<?php else : ?>
<?php echo 'has_no_description'; ?>
<?php endif; ?>
<?php endif; ?>
</section>
<?php endif; ?>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
を動作していないそれはなぜ私の真/偽のフィールドが動作し、どのようにそれはそう両方の状況が表示されます動作させるためにされていない、「has_no_description」値のみを表示します。高度なカスタムフィールドはTrue/Falseのフィールドが
UPDATE:
<?php if(have_rows('team_members')): ?>
<?php while(have_rows('team_members')): the_row(); ?>
<div class="team-member-section">
<div class="container">
<?php if(get_row_layout() == 'team_members'): ?>
<section class="team-member-section">
<?php
$team_title = get_sub_field('team_title');
$team_member = get_sub_field('team_member');
$description = get_sub_field('description');
?>
<div class="team-title">
<?php echo $team_title; ?>
</div>
<?php if($team_member): ?>
<?php if (get_field('has_description')) : ?>
<?php foreach($team_member as $post): ?>
<?php setup_postdata($post); ?>
<div class="col-sm-4">
<div class="team-member">
<div class="member-img">
<?php the_post_thumbnail(); ?>
</div>
<h4><?php the_title(); ?></h4>
<?php the_content(); ?>
<?php echo "Has description"; ?>
<?php $overlay_text = get_field('overlay_text'); ?>
<?php if($overlay_text != ''): ?>
<div class="overlay-text">
<p><?php echo $overlay_text; ?></p>
</div>
<?php endif; ?>
</div>
</div>
<?php wp_reset_postdata(); ?>
<?php endforeach; ?>
<?php else : ?>
<?php foreach($team_member as $post): ?>
<?php setup_postdata($post); ?>
<div class="col-sm-4">
<div class="team-member">
<div class="member-img">
<?php the_post_thumbnail(); ?>
</div>
<h4><?php the_title(); ?></h4>
<?php the_content(); ?>
<?php echo "Doesn not have description"; ?>
<?php $overlay_text = get_field('overlay_text'); ?>
<?php if($overlay_text != ''): ?>
<div class="overlay-text">
<p><?php echo $overlay_text; ?></p>
</div>
<?php endif; ?>
</div>
</div>
<?php wp_reset_postdata(); ?>
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>
</section>
<?php endif; ?>
</div>
</div>
<?php endwhile; ?>
私は私の全体のコードを掲載しました。 ここでの問題は、フィールド 'has_description'が「チーム」カスタム投稿タイプでのみ表示されていることで、フィールドがnullを返す理由ですが、わかりません。誰かがそれを働かせることができますか?
<?php if(get_field( 'has_description')== 'yes'):?>ここでフィールド 'has_description'を使用しています –
has_descriptionはtrue/false型で、チェックボックスとして表示されます。 –
いいえ、それはelseブランチだけを表示します。 –