Created
May 8, 2017 18:22
-
-
Save oldlastman/0e2173ecdaffaee2abfe8a59888f6f0b to your computer and use it in GitHub Desktop.
WordPress / woocommerce : Hide excessive category text
This file contains 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
remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10, 2 ); | |
// define the woocommerce_archive_description callback | |
function att_action_woocommerce_archive_description( ) { | |
if ( is_product_taxonomy() && 0 === absint( get_query_var( 'paged' ) ) ) { | |
$description = term_description(); | |
$description_array = explode('<!--more-->',$description ); | |
if (count($description_array)==2){ | |
$description = $description_array[0]; | |
$description .= ' | |
<a href="javascript:jQuery(this).click(jQuery(\'#category_hidden_text\').toggle())">Saber más...</a> | |
<div id="category_hidden_text" style=\'display:none;\'> | |
'; | |
$description .= $description_array[1]; | |
$description .= '</div>'; | |
} | |
$description = wc_format_content( $description ); | |
if ( $description ) { | |
echo '<div class="term-description">' . wc_format_content($description) . '</div>'; | |
} | |
} | |
}; | |
// add the action | |
add_action( 'woocommerce_archive_description', 'att_action_woocommerce_archive_description', 10, 2 ); |
Hello, thank you for nice work. Maybe you know why showing in Firefox after press read more this ( [object Object] )
having error on line 15 with id tag
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
paste on your functions.php
or on your snippets plugins
on your woocommerce category add "more" tag (< ! --more - - >):
regards