Good morning! I am not able to implement a forech in a database search using the native wordpress variables, searching I found something similar but it is not what I need.
<?php global $post;
$args = array('category' => 17);
$custom_posts = get_posts($args);
foreach($custom_posts as $post) : setup_postdata($post);
...
endforeach;
?>
I want to return the data in a list to change the class from the first search to the second, example below:
<?php global $post;
$args = array('category' => 17);
$custom_posts = get_posts($args);
foreach($custom_posts as $post) : setup_postdata($post);
<div class="divA">
</div>
<div class="divB">
</div>
endforeach;
?>
Returning:
<div class="divA">
Teste 1
</div>
<div class="divB">
Teste 2
</div>
<div class="divA">
Teste 3
</div>
<div class="divB">
Teste 4
</div>
Would it be possible?