I am a complete noob when it comes to woocommerce so bear with me. I have added 6 products into woo. I have a cart and a checkout page that are using shortcodes to output the php/html to those respective pages, now I know I can Edit files in an upgrade-safe way using overrides per the woo documentation. I have successfully modified these pages using that technique.
Also I am using the understrap-child theme, since it is custom do I need to add add_theme_support
in my functions.php? as described in the woo docs.
Now getting to what I want to achieve. I want to create a new page in wordpress, lets call it all-products
I want to loop through all my products and display them on the page, I also want to access the php file that I can overide html and php for that page, How would I do this. I don't see a shortcode to output all my products. This is where I am stuck. I can clarify this question if it is not clear enough. Would I create a page-products
in my theme and use a theming snippet like below?
<ul class="products">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 12
);
$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();
?>
</ul><!--/.products-->
Also is it better to use hooks to overide certain templates as described here could someone explain how do this hooks thing, I don't quite get where the code ends up.
Thanks! ahead of time.