Created
October 7, 2020 18:27
-
-
Save cpaul007/d2d2e132fcc65091990a3da64ac1309f to your computer and use it in GitHub Desktop.
Product Category Description with Link
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('woocommerce_after_subcategory_title', 'ou_display_category_description_link', 10, 1); | |
function ou_display_category_description_link( $category ) { | |
/** | |
* Returning early if it is not a home page | |
* You will change the condition logic based on your template settings | |
*/ | |
if( ! is_front_page() ) | |
return; | |
if ( $category && ! empty( $category->description ) ) { | |
echo '<div class="term-description">'; | |
/** | |
* Displaying the category description (max limit 120) | |
* | |
* If you want to show full description replace the following line | |
* wpautop( wc_trim_string( $category->description, 120 ) ) with wc_format_content( $category->description ) | |
*/ | |
echo wpautop( wc_trim_string( $category->description, 120 ) ); | |
//* Adding the category archive page link | |
printf('<p class="product-cat-term-link"><a href="%s" rel="permalink">Read More →</a></p>', get_term_link( $category ) ); | |
echo '</div>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment