Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @moshe1111,

    Use the same code but replace the number 100 in this line with the number of characters of your choice:

    $excerpt = substr($excerpt, 0, 100);

    Hope this helps. Best of luck with your website

    Thread Starter moshe

    (@moshe1111)

    Hello
    Not working for me

    Hello @moshe1111,

    The code does function, I just tested it again on our end to double-check.

    Make sure you haven’t missed anything and that you’ve cleared your browser cache afterwards.

    To clarify, if you want to display 300 characters, this line should be:
    $excerpt = substr($excerpt, 0, 300);

    The rest of the code remains the same

    • This reply was modified 4 years, 7 months ago by Marko OceanWP.
    Thread Starter moshe

    (@moshe1111)

    Hello
    This is what the code looks like on my site

    function get_ecommerce_excerpt(){
      $excerpt = get_the_excerpt();
      $excerpt = preg_replace(" ([.*?])",'',$excerpt);
      $excerpt = strip_shortcodes($excerpt);
      $excerpt = strip_tags($excerpt);
      $excerpt = substr($excerpt, 0, 999);
      $excerpt = substr($excerpt, 0, strripos($excerpt, " "));
      $excerpt = trim(preg_replace( '/s+/', ' ', $excerpt));
      return $excerpt;
    }
    
    function prefix_short_des_product() {
        echo get_ecommerce_excerpt();
    }
    add_action( 'ocean_after_archive_product_title', 'prefix_short_des_product', 40 );

    Snippet Code

    Thread Starter moshe

    (@moshe1111)

    And it doesn’t even show 100. Maybe 50.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Can the description be expanded to more characters?’ is closed to new replies.