Skip to content

Instantly share code, notes, and snippets.

@macdabby
Created August 11, 2021 02:22
Show Gist options
  • Save macdabby/421c5132d9394a8199b9d2b5d8f5d15b to your computer and use it in GitHub Desktop.
Save macdabby/421c5132d9394a8199b9d2b5d8f5d15b to your computer and use it in GitHub Desktop.
Custom shop page for woocommerce
<?php
/**
* ORIGINAL COMMENT FROM WOOCOMMERCE - this is the file that has been modified and exists in the active theme
*
*
*
*
* The Template for displaying product archives, including the main shop page which is a post type archive
*
* This template can be overridden by copying it to yourtheme/woocommerce/archive-product.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce\Templates
* @version 3.4.0
*/
defined( 'ABSPATH' ) || exit;
get_header( 'shop' );
//do_action( 'woocommerce_archive_description' );
// this is added because i'm using livecanvas and this is required for the editor. normally it's added in with a hookk but it seems woocommerce is disabling that
echo '<main id="lc-main">';
if ( have_posts() ) :
while ( have_posts() ) : the_post();
the_content();
// break so only the main product page is shown and not products
break;
endwhile;
else :
_e( 'Sorry, no posts matched your criteria.', 'textdomain' );
endif;
echo '</main>';
//<?php
/**
* Hook: woocommerce_after_main_content.
*
* @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
*/
do_action( 'woocommerce_after_main_content' );
get_footer( 'shop' );
@macdabby
Copy link
Author

I was trying to create a custom shop page using short tags to put the products where I wanted under different sections. i had designed a page that looked perfect, but when i set it to the 'shop' page in the WC settings, it would automatically change the master template and add the products after my page (which already included the products).
this is probably going to break the category pages, but I am not using those on this site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment