Home Forums Basel support forum Titles Limit at homepage

Titles Limit at homepage

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10419

    mrlekman
    Participant

    Hello I want to limit the Titles because i have some very big titles. I set this:

    // Automatically shortens WooCommerce product titles on the main shop, category, and tag pages
    // to a specific number of words
    function short_woocommerce_product_titles_words( $title, $id ) {
    if ( ( is_shop() || is_product_tag() || is_product_category() ) && get_post_type( $id ) === ‘product’ ) {
    $title_words = explode(” “, $title);
    if ( count($title_words) > 5 ) { // Kicks in if the product title is longer than 5 words
    // Shortens the title to 5 words and adds ellipsis at the end
    return implode(” “, array_slice($title_words, 0, 5)) . ‘…’;
    } else {
    return $title; // If the title isn’t longer than 5 words, it will be returned in its full length without the ellipsis
    }
    } else {
    return $title;
    }
    }
    add_filter( ‘the_title’, ‘short_woocommerce_product_titles_words’, 10, 2 );

    But it changes only at categories. I also want the changes for the products shown at the homepage. How can I do this?

    #10420

    Artem Temos
    Keymaster

    Hello,

    Sorry, but your question is related to the additional code customization and it is out of our theme support scope. We can’t help you with any third party code snippets added to the theme.

    Thank you for understanding.

    Regards

Viewing 2 posts - 1 through 2 (of 2 total)