• Resolved TrishaM

    (@trisham)


    I like the layout provided by EDD for my digital downloads, but need some simple HTML to be allowed in the excerpt shown for each downloadable item.

    I have always used a standard snippet of code, which I’ll paste below, but it doesn’t work in this case (it works elsewhere that WP displays excerpts, just not with my Downloads).

            function improved_trim_excerpt($text) {
    	$raw_excerpt = $text;
    	if ( '' == $text ) {
    		$text = get_the_content('');
    		$text = strip_shortcodes( $text );
    		$text = apply_filters('the_content', $text);
                    $text = str_replace('\]\]\>', ']]>', $text);
    		$text = strip_tags($text, '<b><del><em><small><span><strong>');
    		$excerpt_length = apply_filters('excerpt_length', 60);
                    $newexcerpt_more = apply_filters('excerpt_more', 'new_excerpt_more');
    		$words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
    		if ( count($words) > $excerpt_length ) {
    			array_pop($words);
    			$text = implode(' ', $words);
    			$text = $text . $newexcerpt_more;
    			$text = force_balance_tags( $text );
    		} else {
    			$text = implode(' ', $words);
    			$text = force_balance_tags( $text );
    		}
    	}
    	return $text;
            }
            remove_filter('get_the_excerpt', 'wp_trim_excerpt');
            add_filter('get_the_excerpt', 'improved_trim_excerpt');

    How can I incorporate this code with the EDD plugin so that my excerpts can make use of a few basic styles?

    Thanks for any help you can offer!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Daniel

    (@dgoldak)

    Hi @trisham ! While we do not normally provide assistance with custom code, this should point you in the right direction.

    You should be able to run his existing function on the edd_downloads_excerpt filter, which just has the $excerpt (text) as its only parameter. For example:

    add_filter( 'edd_downloads_excerpt', 'improved_trim_excerpt' );

    You may also want to remove the core EDD filter that’s run on that same filter:

    remove_filter( 'edd_downloads_excerpt', 'edd_downloads_default_excerpt' );

    Hope that helps!

    Thread Starter TrishaM

    (@trisham)

    Thanks @dgoldak, I deeply appreciate the help and totally understand about not providing assistance with custom code, no worries.

    Sadly though, this solution doesn’t work, I’ve been at it all morning trying to figure out why not, as it makes perfect sense to remove the EDD filter and add the filter to run the new excerpt function.

    I’ve tried clearing my browser cache, flushing the WP cache using both Settings>Permalinks (make a minor change and save it) and flush_rewrite_rule() in the functions.php (on any ‘save’ of a ‘download’ post), and moving that Improved Trim Excerpt code snippet to it’s own plugin after adding the Plugins Load Order plugin and ensuring that my plugins load after the EDD & Music Player plugins….no dice….

    What’s odd is that it works perfectly on standard WP posts and pages where I call the_excerpt(), just not on the downloads page that lists all my downloads with their excerpts. ??

    So next I will try creating a template file to see if altering the layout will let me control the styles of the excerpts, I just hate to go that route because I’d rather find a solution that will continue to work as Themes and Plugins get updated without my needing to keep a custom template updated as well.

    Thread Starter TrishaM

    (@trisham)

    WELL I had a breakthrough!

    I’ve been pouring over your TERRIFIC documentation (it’s truly impressive as far as plugin docs goes)….and my eye happened upon a parameter for the [downloads] shortcode called “full_content”……

    SO I added that with a ‘yes’ and now my list of downloads shows the full content (which was short anyway) and it is using my HTML styles – so, success!

    I still don’t know why the excerpt filter override doesn’t work, but at this point I’m doing a victory dance because happy client = happy life.

    Marking this as resolved.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Need HTML in Excerpt’ is closed to new replies.