WordPress.org

Support

Support » Plugins and Hacks » How to trim/short the title

How to trim/short the title

  • Hi Guys

    i Like to know how to trim / short the title for wordpress ecommerce

    currently i am using
    <?php echo wpsc_the_product_title(); ?> for ecommerce

    for normal wordpress post and page i use

    function short_title($after = '', $length) {
    	$mytitle = get_the_title();
    	if ( strlen($mytitle) > $length ) {
    	$mytitle = substr($mytitle,0,$length);
    	echo $mytitle . $after;
    	} else {
    	echo $mytitle;
    	}
    }

    <?php short_title('...', 40); ?>

  • The topic ‘How to trim/short the title’ is closed to new replies.
Skip to toolbar