• 0
Sign in to follow this  
Followers 0

AnyLoop Ellipsis on AnyLoop Compact Post Titles

Question

Posted · Report post

I'm using AnyLoop in a box (one in each box as is shown in the attached image), to display the most recent posts from a specific category.

The post titles are not styled as I prefer and I am trying to truncate them to overflow breakpoint. As I understand it, text-overflow: ellipsis; needs a width setting to work.

 

How can I achieve this while still maintaining the responsive nature of the page?

 

 

Share this post


Link to post
Share on other sites

2 answers to this question

  • 0

Posted · Report post

So, I solved limiting the ellipsis to AnyLoop myself!  :D 
 

// LIMITS THE POST TITLE TO 30 CHARACTERS IF NOT IN THE POST LOOP //
function titlelimitchar($title){
	if(!in_the_loop() && !is_page() && strlen($title) > 30 && !(is_single()) && !(is_page())){
		$title = mb_substr($title,0,30) . "…";
	}
	return $title;
}

add_filter( 'the_title', 'titlelimitchar' );
1 person likes this

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Well, afters hours of searching and experimenting I finally got this work work (sort of):

// LIMITS THE POST TITLE TO 30 CHARACTERS //
function titlelimitchar($title){
	if(strlen($title) > 30 && !(is_single()) && !(is_page())){
		$title = mb_substr($title,0,30) . "…";
	}
	return $title;
}
add_filter( 'the_title', 'titlelimitchar' );

Of course that code affects all post titles on the home/blog page, not just those in an AnyLoop.

 

Does AnyOne have ideas on:

  • how to restrict this to AnyLoop?
  • refigure the code to back up to the beginning of the word being truncated and place the ellipsis there instead of cutting off the word?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0