Help > Forum > Themes & Appearance > Limiting the height of posts

Limiting the height of posts

You can use the instructions below to limit the height of posts. Users can click a "Read more" link to expand posts that have had their height limited.

  1. Log in to your Website Toolbox account.
  2. Click the Appearance link.
  3. In the Appearance menu, click the HTML link.
  4. Insert the following code into the Forum Head Tag HTML Code textbox:
    <script>
    	window.addEventListener('load', (event) => {
    		if (jQ(".wt-post-listing").length) {
    			jQ(".post-body-content").each(function(){
    				if (jQ(this).children("[id^='post_message_']").outerHeight() > 300) {
    					jQ(this).children("[id^='post_message_']").addClass('read-more-enabled').after('<a class="cleared text-block custom-read-more-link"><i>Read more ›</i></a>');
    				}
    			});
    			jQ(".custom-read-more-link").click(function(){
    				jQ(this).addClass('hidden').prev('.read-more-enabled').removeClass('read-more-enabled');
    			});
    		}
    	});
    </script>
    <style>
    	.wt-post-listing .post-body-content > [id^='post_message_'] {
    		float: left;
    		width: 100%;
    	}
    	.wt-post-listing .post-body-content > [id^='post_message_'].read-more-enabled {
    		max-height: 300px;
    		overflow: hidden;
    	}
    </style>
  5. Save the changes.


If you still need help, please contact us.