WordPress.org

Ready to get started?Download WordPress

Forums

How to trim/short the title (1 post)

  1. xinfo
    Member
    Posted 3 years ago #

    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); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags