1
Hello, all right.
I have a question here and I’d like a little help from you
I have the following code:
<?php $prod_marca = get_field('categoria_e_tags_marca');
if( $prod_marca ): ?>
<ul>
<li><b>Marca</b></li>
<?php foreach( $prod_marca as $term ): ?>
<li class="text-small-lista"><?php echo $term->name; ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
In this code I pull a field of Advanced Custom Field that returns me several categories, but I don’t want to print all categories, I want to limit the number of categories that will be printed.
Today the layout breaks because it appears in a block 5 categories and in another block 20 categories.
I wanted to limit to 5 categories only, IE, no matter how many categories are set in admin, will only print 5.
Will I be able to make clear the help I need?
Thanks in advance to all who can help me with this doubt.
Att...
A friend passed me the following information that solved my problem
<?php foreach( array_slice($prod_marca, 0, 5) as $term ): ?>
– Wesley Oliveira