I have a huge issue and I broke my had trying to find the correct solution. I have a following loop code. This loop is inside my page-product.php file:
<?php
$terms = get_the_terms( get_the_ID(), 'colour' );
if ( $terms && ! is_wp_error( $terms ) ) :
?>
<section class="colour__chart">
<div class="container">
<div class="row">
<div id="color-chart">
<h2>Colour Chart</h2>
<?
$terms = get_the_terms( get_the_ID(), 'colour' );
if( $terms && ! is_wp_error( $terms ) ){
foreach( $terms as $term ){
echo get_field( 'name', 'colour_' . $term->term_id );
echo '<div class="col-md-2 col-sm-4 col-xs-4 text-center">';
echo '<div class="color-chart__item" style="background-color:' . get_field( 'colour_acf', 'colour_' . $term->term_id ) . '"></div>';
echo '<p>' . $term->name . '</p>' ;
echo '</div>' ;
}
}
?>
</div>
</div>
</div>
</section>
<?php endif; ?>
and everything worked great before today. Suddenly the loop stopped working and instead of its correct displaying in the front-end I see only this text:
'; echo '
'; echo '
' . $term->name . '
' ; echo '
I've attached a screenshot also. Would appreciate any help.
I have a huge issue and I broke my had trying to find the correct solution. I have a following loop code. This loop is inside my page-product.php file:
<?php
$terms = get_the_terms( get_the_ID(), 'colour' );
if ( $terms && ! is_wp_error( $terms ) ) :
?>
<section class="colour__chart">
<div class="container">
<div class="row">
<div id="color-chart">
<h2>Colour Chart</h2>
<?
$terms = get_the_terms( get_the_ID(), 'colour' );
if( $terms && ! is_wp_error( $terms ) ){
foreach( $terms as $term ){
echo get_field( 'name', 'colour_' . $term->term_id );
echo '<div class="col-md-2 col-sm-4 col-xs-4 text-center">';
echo '<div class="color-chart__item" style="background-color:' . get_field( 'colour_acf', 'colour_' . $term->term_id ) . '"></div>';
echo '<p>' . $term->name . '</p>' ;
echo '</div>' ;
}
}
?>
</div>
</div>
</div>
</section>
<?php endif; ?>
and everything worked great before today. Suddenly the loop stopped working and instead of its correct displaying in the front-end I see only this text:
'; echo '
'; echo '
' . $term->name . '
' ; echo '
I've attached a screenshot also. Would appreciate any help.
While <?
was once a valid php opener, you should be using <?php
.
Try changing this line:
<h2>Colour Chart</h2>
<?
to
<h2>Colour Chart</h2>
<?php
That should allow the php to be read correctly.
<h2>color chart</h2 <?
to<h2>color chart</h2 <?php
– rudtek Commented Feb 13, 2019 at 20:12