Thursday 14 February 2013

Wordpress Eshop Plugin - shorten description in shortcode

Using Wordpress's Eshop plugin; I'm making category pages for my products and I'm using the eshop_list_subpages shortcode. 

What I'd like to do is shorted the description down and add a price.

Adding a price is easy all you need to do is change the shortcode to

[eshop_list_subpages price="yes"]

However I couldn't find an attribute for the text length so added this hack. 

If you want it wouldn't be too difficult to make a new attribute for the shortcode. Although due to time constrictions on this job, a quick fix had to do.

OPEN

wp-content/plugins/eshop/eshop-shortcodes.php

FIND

 $echo .= apply_filters('eshop_list_excerpt',apply_filters('the_excerpt', get_the_excerpt()), $post->ID);
       

REPLACE WITH

/* littleripples.com changes  - the below line has been replaced to shorten the description
         $echo .= apply_filters('eshop_list_excerpt',apply_filters('the_excerpt', get_the_excerpt()), $post->ID);
         with -> */
        $desc =  apply_filters('eshop_list_excerpt',apply_filters('the_excerpt', get_the_excerpt()), $post->ID);
        list($shortdesc) = explode("\n",wordwrap($desc,100));
         $echo .= $shortdesc.'

';
// end of littleripples.com changes.

No comments: