Skip Navigation

[Resolved] Implement a read more link/button with post excerpts or post content fields

This thread is resolved. Here is a description of the problem and solution.

Problem:
I'd like to implement a read more link/button with post excerpts or post content fields.
When I click on it the text should expand immediately.

Solution:
Solution here:
https://toolset.com/forums/topic/implement-a-read-more-linkbutton-with-post-excerpts-or-post-content-fields/#post-588643

This support ticket is created 7 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 6 replies, has 2 voices.

Last updated by Nicholas 7 years ago.

Assisted by: Noman.

Author
Posts
#588401
Screen Shot 2017-11-10 at 10.10.34 AM.png

Hello I'd like to implement a read more link/button with post excerpts or post content fields. (see image)
When I click on it the text should expand immediately.
For example limit the post excerpt to 50 characters and then when I click the button the entire excerpt should display.
How's this possible?

Regards,
Nicolas

#588495

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Nicholas,

Thank you for contacting Toolset support. we have another client who had the similar issue and luckily was also able to solve it, this may help in your case:
https://toolset.com/forums/topic/wpv-post-excerpt-read-more-link/#post-217884

Thank you

#588503

Hello not quite what I wanted, as I would like to implement this on the post itself.
When I click on the read more button the text should expand immediately.
For example limit the post excerpt to 50 characters and then when I click the button the entire excerpt should display.

How is this possible?

Regards,
Nicholas

#588633

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

We can do that with JS code as Toolset does not have anything like this. I am trying few things at my end and will let you know my findings soon.

Thanks

#588634

Thank you.

#588643

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hello,

Can you please confirm that you want to have something like on this site -- click on ...Lees Meer (read more): hidden link

If yes, you can achieve this using following HTML, CSS and JS:

HTML code:

<article class="news-post-section open">
  <div class="title-bar clearfix">
    <h2 class="post-title"><a href="#">Title</a></h2>
  </div>
  <div class="post-inner-content clearfix">
    <div class="post-excerpt">
      <p>Content goes here</p>
      <p>Content goes here</p>
      <p>Content goes here</p>
    </div>
    <a href="#" class="btn-read-more">Toon Minder</a> 
   </div>
</article>

==> Please update the html code or shortcodes in the above example code with your own content and modify as needed.

CSS code:
You may need to change max-height: 145px to your required value.

.post-excerpt {
    line-height: 1.9;
    max-height: 145px;
    overflow: hidden;
    transition: max-height 0.15s ease-out 0s;
}

.news-post-section.open .post-excerpt {
    max-height: 1000px;
    overflow: visible;
    transition: max-height 0.25s ease-in 0s;
}

JS code:

jQuery(document).ready(function( $ ){


$('.news-post-section').each(function(index, element) {
		var cont_len = $(this).find('.post-excerpt').height();
		if( cont_len < 145 )
			$(this).find('.btn-read-more').hide('fast');
	});

$('.btn-read-more').on('click',function(e){
	if($(this).parents('.news-post-section').hasClass('open')){
		$(this).parents('.news-post-section').removeClass('open');
		$(this).text('...Lees Meer');
	}
	else{
		$(this).parents('.news-post-section').addClass('open');
		$(this).text('Toon Minder');
	}
	e.preventDefault();
});

});

==> Please update the JS code or text in the above example with your own and modify as needed.

Thanks

#590840

This is resolved.