get_template_part – Custom
-
Hi, I would like to know how to make a get_template_part work with more than one template, passing through an array.
Example:
arrayarray(2) { [0]=> array(1) { ["model_card"]=> string(10) "card-col-8" } [1]=> array(1) { ["model_card"]=> string(10) "card-col-3" } } if (have_posts()) { $i = 0; while(have_posts()) { the_post(); set_query_var( 'category_slug', $category_slug ); set_query_var('post_type', $post_type); get_template_part( 'template-parts/content', $cards[$i]['model_card']); $i++; }
I can not do in the loop the second posts get the second position of the array and so go to another layout. It always puts all posts in the first position of the array.
Can someone help me?
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘get_template_part – Custom’ is closed to new replies.