Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oldlastman/0e2173ecdaffaee2abfe8a59888f6f0b to your computer and use it in GitHub Desktop.
Save oldlastman/0e2173ecdaffaee2abfe8a59888f6f0b to your computer and use it in GitHub Desktop.
WordPress / woocommerce : Hide excessive category text
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 );
@oldlastman
Copy link
Author

oldlastman commented May 8, 2017

paste on your functions.php
or on your snippets plugins
on your woocommerce category add "more" tag (< ! --more - - >):

  • over your tag show text and insert "saber mas" (~read more)
  • bellow your tag hide text

regards

@sakalcik
Copy link

Hello, thank you for nice work. Maybe you know why showing in Firefox after press read more this ( [object Object] )

@mrshafaq
Copy link

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