Community Forums › Forums › Archived Forums › Design Tips and Tricks › Losing formatting when displaying limited content
Tagged: content archives, formatting
- This topic has 6 replies, 3 voices, and was last updated 10 years, 4 months ago by
Tony.
-
AuthorPosts
-
November 12, 2015 at 4:06 pm #170937
Christina
ParticipantSo 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 #170950Marcy
ParticipantThat'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 #170980Christina
ParticipantThat'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 #170995Marcy
ParticipantDecember 12, 2015 at 12:10 pm #173627Tony
MemberI'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 #173629Marcy
ParticipantYou 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 #173630Tony
MemberThank 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.
-
AuthorPosts
- The topic ‘Losing formatting when displaying limited content’ is closed to new replies.