I need to be able to display woocommerce category descriptions part above and part below product archives. There are plugins that do this but they display information above and below woocommerce shop loop hooks (like woocommerce_after_shop_loop) but this displays information below products at the right/left side of the filter column and I need the information to be displayed part above and part below filter column and shop loop.
I'm using Porto theme and you can visually see what I mean here: https://www.portotheme.com/wordpress/porto/documentation/page-layouts/
Plugins display the category descriptions in the "Content Inner Top" and/or "Content Inner Bottom" blocks.
And I need the category descriptions to be displayed in the "Content Top or Banner (Page Headers)" and/or "Content Bottom" blocks.
I'm using "Product Categories/Tags Bottom Description for WooCommerce" (https://wordpress.org/plugins/product-categories-bottom-description-woo-comerce/) plugin that includes a shortcode to display category descriptions in the "Banner (Page Headers)" block. But I have not found another plugin that includes shortcodes so I found this other simple one "Category Description for WooCommerce" (https://wordpress.org/plugins/category-description-for-woocommerce/) and was wondering if there is a way to add code to include a shortcode so I can place it in the "Content Bottom" block.
This is the code that echos the category description below the product archive:
add_action( 'woocommerce_after_shop_loop', function () { echo '<div class="custom-category-description">' . wp_kses_post( wpautop( $this->plugin_settings['description'] ) ) . '</div>'; }
Can someone help me with code so instead of echo-ing the category description, make it display it in a shortcode that I can add to the "Content Bottom" Porto block?
This code is in this plugin file: /wp-content/plugins/category-description-for-woocommerce/includes/class-cdfwsp-category-descriptin-for-woo-frontend.php
I would greatly appreciate any help with this.
This is what I tried so far. In the plugin code, I changed the original "woocommerce_after_shop_loop" hook and used this "porto_before_content_bottom" porto hook:
add_action( 'porto_before_content_bottom', function () { echo '<div class="custom-category-description">' . wp_kses_post( wpautop( $this->plugin_settings['description'] ) ) . '</div>'; }
This does display this plugins category description where I want it but I can't use Porto elements or options to enhance the placement, paddings, margins, etc. Using a shortcode I can use all these options.
You can create a shortcode to display the category description saved in your plugin settings. Add this code:
add_shortcode( 'woo_category_description', function( $atts ) {
if ( ! empty( $this->plugin_settings['description'] ) ) {
return '<div class="custom-category-description">' .
wp_kses_post( wpautop( $this->plugin_settings['description'] ) ) .
'</div>';
}
return '';
} );
Now, you can use the shortcode [woo_category_description]
anywhere (e.g., in a page, post, or widget), and it will output the custom category description.