Home › Forums › Basel support forum › Need Full Width Category Banner In Product Category Urgent › Reply To: Need Full Width Category Banner In Product Category Urgent
September 29, 2018 at 3:39 pm
#79828
Elise Noromit
Member
Hello,
Please add this snippet to the functiions.php of the child theme:
function basel_custom_desc_position() {
remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 );
remove_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description', 10 );
add_action( 'woocommerce_before_main_content', 'basel_taxonomy_archive_description', 1 );
add_action( 'woocommerce_before_main_content', 'basel_product_archive_description', 2 );
}
add_action( 'wp', 'basel_custom_desc_position', 1000 );
function basel_taxonomy_archive_description() {
if ( is_product_taxonomy() && 0 === absint( get_query_var( 'paged' ) ) ) {
$term = get_queried_object();
if ( $term && ! empty( $term->description ) ) {
echo '<div class="term-description custom-desc-class col-sm-12 col-xs-12 col-12">' . wc_format_content( $term->description ) . '</div>'; // WPCS: XSS ok.
}
}
}
function basel_product_archive_description() {
// Don't display the description on search results page.
if ( is_search() ) {
return;
}
if ( is_post_type_archive( 'product' ) && in_array( absint( get_query_var( 'paged' ) ), array( 0, 1 ), true ) ) {
$shop_page = get_post( wc_get_page_id( 'shop' ) );
if ( $shop_page ) {
$description = wc_format_content( $shop_page->post_content );
if ( $description ) {
echo '<div class="page-description custom-desc-class col-sm-12 col-xs-12 col-12">' . $description . '</div>'; // WPCS: XSS ok.
}
}
}
}
And this code to the Theme Settings > Custom CSS:
.custom-desc-class {
margin-bottom: 20px;
}
Best Regards