reusing code in function and running it with loop
You would need to set up the function like this in your functions.php function my_function(){ //your function in here include(TEMPLATEPATH . ‘[variable][1].php’); } And then in your loop you would call it like so: $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 4, ); $featured_query = new WP_Query($args); if ($featured_query->have_posts()) { while ($featured_query->have_posts()) { $featured_query->the_post(); … Read more