I'm new to WordPress and editing StoreFront Woo Commerce theme, I have the code but have no clue where to put it, everyone gives the answer without mentioning the location to change the file, please help!
<ul class="products">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 12,
'tax_query' => array(
array(
'taxonomy' => 'product_visibility',
'field' => 'name',
'terms' => 'featured',
),
),
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
wc_get_template_part( 'content', 'product' );
endwhile;
} else {
echo __( 'No products found' );
}
wp_reset_postdata();
?>
Code that changes the way WordPress and plugins function is usually put into your theme's functions.php file. The <ul class="products">
is straight HTML and should not be placed in that file unless it is being processed as an echo or print output of some kind.
Since most themes get an update at some point, you should be using a child theme to make modifications.