• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Trying to restore tags to the excerpt, needing paragraphs to display correctly

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Trying to restore tags to the excerpt, needing paragraphs to display correctly

This topic is: not resolved

Tagged: brad dalton, Excerpt, paragraph, replace, tags

  • This topic has 3 replies, 1 voice, and was last updated 8 years, 4 months ago by David Borrink.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • December 2, 2016 at 9:21 am #196930
    David Borrink
    Participant

    I used the code below to restore the stripped tags in front page excerpts. It works fine except that my paragraphs are still merged into one block up to the excerpt limit cutoff.

    // Add html to archive content limit.
    add_filter( 'get_the_content_limit_allowedtags', 'custom_get_the_content_limit_allowedtags' );
    function custom_get_the_content_limit_allowedtags() {
    
    	return '<script>,<style>,<strong>,<b>,<br>,<em>,<i>,<ul>,<ol>,<li>,<a>';
    }

    I tried adding <p> to the list of tags above to return, but that doesn't do anything because the "text" mode in the visual editor doesn't have <p> tags. Is there any way to get paragraphs to be separated?

    We just moved from a TwentyTwelve child theme to Genesis, so the excerpt replace function I used before won't apply here. We had paragraphs breaking in the excerpt on that theme with the following code:

    function my_custom_excerpt($text) {
    	global $post;
    	if ( '' == $text ) {
    		$text = get_the_content('');
    		$text = apply_filters('the_content', $text);
    		$text = str_replace('\]\]\>', ']]>', $text);
    		$fulltext = str_replace('\]\]\>', ']]>', $text);
    		$text = strip_tags($text, '<p><a>');
    		$excerpt_length = 100;
    		$words = explode(' ', $text, $excerpt_length + 1);
    		if (count($words) > $excerpt_length) {
    			array_pop($words);
    			array_push($words, '... <a href="'. esc_url( get_permalink() ) . '">Read more ยป</a>');
    			$text = implode(' ', $words);
    		}
    		else {
    			$text = $fulltext;
    		}
    	}
    	return $text;
    }
    remove_filter('get_the_excerpt', 'wp_trim_excerpt');
    add_filter('get_the_excerpt', 'my_custom_excerpt');
    http://sallieborrink.com
    December 17, 2016 at 7:43 pm #197756
    David Borrink
    Participant

    Okay, I found that I had an unnecessary function from my old TwentyTwelve based theme that might have been interfering with the new function I listed above. I tried the code example from Brad Dalton above again and I'm still getting the same issue. If my excerpt has an italic tag that doesn't close before the excerpt cut-off, the rest of my page and sidebars are show up in italics. How can I retain the tag formatting without sending the rest of the page into tag chaos?

    And I'm not getting paragraph breaks if I add <p> to the string of tags.

    January 26, 2017 at 1:57 pm #200086
    David Borrink
    Participant

    I don't know if bumping is allowed, so I'm bumping one month later.

    February 17, 2017 at 12:24 pm #201395
    David Borrink
    Participant

    Anyone?

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble