我确信这很简单,但如果不打破我的页面,我就无法得到这个:
<?php
$values = get_field('testimonial_text');
if($values) {
echo '
<div class="testimonial entry-content">
<h2><?php the_field('testimonial_title'); ?></h2>
<?php the_field('testimonial_text'); ?>
</div>';
} else {
echo '';
}
?>
Run Code Online (Sandbox Code Playgroud)
有人能告诉我我做错了什么,为什么我做的不行.
你有嵌套<?php .. ?>块.这表明出现了问题!
<?php
$values = get_field('testimonial_text');
if($values) {
echo '<div class="testimonial entry-content">';
echo '<h2>'; the_field('testimonial_title'); echo '</h2>';
the_field('testimonial_text');
echo '</div>';
}
// your else was a no-op, so I removed it
?>
Run Code Online (Sandbox Code Playgroud)