Home › Forums › Support › ! exist woocommerce wrappers › Reply To: ! exist woocommerce wrappers
June 29, 2016 at 11:46 am
#205434
GL
Just tested, works, here’s my crazy function in case anyone wants to change just the single product page in the future:
add_action( 'after_setup_theme','generate_redo_woocommerce_wrappers' );
function generate_redo_woocommerce_wrappers()
{
remove_action('woocommerce_before_main_content', 'generate_woocommerce_start', 10 );
remove_action('woocommerce_after_main_content', 'generate_woocommerce_end', 10 );
add_action('woocommerce_before_main_content', 'generate_child_woocommerce_start', 10 );
add_action('woocommerce_after_main_content', 'generate_child_woocommerce_end', 10 );
}
if ( ! function_exists( 'generate_child_woocommerce_start' ) ) :
function generate_child_woocommerce_start()
{
if ( is_product() ) {
return;
} else {
?>
<div id="primary" <?php generate_content_class();?>>
<main id="main" <?php generate_main_class(); ?>>
<?php do_action('generate_before_main_content'); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php generate_article_schema( 'CreativeWork' ); ?>>
<div class="inside-article">
<?php do_action( 'generate_before_content'); ?>
<div class="entry-content" itemprop="text">
<?php
}
}
endif;
if ( ! function_exists( 'generate_child_woocommerce_end' ) ) :
function generate_child_woocommerce_end()
{
if ( is_product() ) {
return;
} else {
?>
</div>
<!-- .entry-content -->
<?php do_action( 'generate_after_content'); ?>
</div>
<!-- .inside-article -->
</article>
<!-- #post-## -->
<?php do_action('generate_after_main_content'); ?>
</main>
<!-- #main -->
</div>
<!-- #primary -->
<?php
}
}
endif;
I placed the actual wrappers I need to use in the content_single_product template file directly.
It’s kind of do and redo, and I don’t exactly like rewriting the same thing, but I couldn’t figure another way that would work. I tried a call for ( is_product() ) wrapped around various things but that wouldn’t do, so I couldn’t selectively apply ‘after_setup_theme’;