Add Event Excerpt to Archive Template

Seems like it should be simple to add an excerpt of the event's description below each event in the default archive template. I tried using both the_excerpt and the_content as I would with a normal post, but these call the content starting with the date, time and location - which are already there.

How do I do this?

  • Tom Eagles

    @dwood7399 This would need custom coding but if you follow the logic you could use string manipulations like in the example below. Beyond this pointer unfortunately we can't provide custom coding solutions.

    <?php
    $my_excerpt = get_the_excerpt();
    if ( $my_excerpt != '' ) {
    	// Some string manipulation performed
    }
    echo $my_excerpt; // Outputs the processed value to the page
    ?>

    Use get_the_excerpt() to print an excerpt by specifying a maximium number of characters.

    <?php
    the_excerpt_max_charlength(140);
    
    function the_excerpt_max_charlength($charlength) {
    	$excerpt = get_the_excerpt();
    	$charlength++;
    
    	if ( mb_strlen( $excerpt ) > $charlength ) {
    		$subex = mb_substr( $excerpt, 0, $charlength - 5 );
    		$exwords = explode( ' ', $subex );
    		$excut = - ( mb_strlen( $exwords[ count( $exwords ) - 1 ] ) );
    		if ( $excut < 0 ) {
    			echo mb_substr( $subex, 0, $excut );
    		} else {
    			echo $subex;
    		}
    		echo '[...]';
    	} else {
    		echo $excerpt;
    	}
    }
    ?>

    Cheers!

    Tom

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.