• 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

Losing formatting when displaying limited content

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 › Design Tips and Tricks › Losing formatting when displaying limited content

This topic is: resolved

Tagged: content archives, formatting

  • This topic has 6 replies, 3 voices, and was last updated 7 years, 3 months ago by Tony.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • November 12, 2015 at 4:06 pm #170937
    Christina
    Participant

    So when I limit the content displayed in Genesis --> Theme Settings --> Content Archives, the posts get stripped of their formatting. Even though I have it set to "Display Post Content."

    Anyone know how to fix this?

    Thanks!

    November 12, 2015 at 7:14 pm #170950
    Marcy
    Participant

    That's the way it is for either excerpts or limited content. You can change it two ways.

    1. If you want to keep the formatting, you can choose Display Post Content, Set the Limit to 0 or leave blank. This will give you full posts.
    Then within your post you add the "more tag" where you want the post to cut off.
    https://bobwp.com/what-is-the-insert-more-tag/

    2. You can use the Display Post Content with a limit as you have.
    Then copy and paste this at the bottom of your functions.php file. Make sure you back up your functions.php before editing.

    // 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>';
    }

    Marcy | Amethyst Website Design | Twitter

    November 13, 2015 at 7:05 am #170980
    Christina
    Participant

    That's exactly the code I was looking for, thanks so much Marcy! It must have already been in my other themes and I didn't even notice it in there.

    November 13, 2015 at 8:59 am #170995
    Marcy
    Participant

    Glad to help!


    Marcy | Amethyst Website Design | Twitter

    December 12, 2015 at 12:10 pm #173627
    Tony
    Member

    I've put the code below into my functions.php file and it works for the most part, but it still strips all the paragraph tags except for the first one. Does anyone know why that's happening.

    Here's the code:

    add_filter( 'get_the_content_limit_allowedtags', 'get_the_content_limit_custom_allowedtags' );
    /**
    * @author Brad Dalton
    * @example http://wp.me/p1lTu0-a5w
    */
    function get_the_content_limit_custom_allowedtags() {
    	// Add custom tags to this string
    	return '<script>,<style>,<br>,<em>,<i>,<ul>,<ol>,<li>,<a>,<p>,<h2>'; 
    }
    
    December 12, 2015 at 1:07 pm #173629
    Marcy
    Participant

    You need to use the Post Content option then:

    If you want to keep the formatting, you can choose Display Post Content, Set the Limit to 0 or leave blank. This will give you full posts.
    Then within your post you add the “more tag” where you want the post to cut off.

    https://bobwp.com/what-is-the-insert-more-tag/


    Marcy | Amethyst Website Design | Twitter

    December 12, 2015 at 1:11 pm #173630
    Tony
    Member

    Thank you Marcy. I am aware of the more tag, but it would be a labor intensive task to go through 500 posts to insert that tag in each of them.

    It seems the function should work, and it does for all tags except <p> tags beyond the 1st one.

    Just trying to figure out why it leaves in the first paragraph tag but not the rest.

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Losing formatting when displaying limited content’ is closed to new replies.

CTA

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

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 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