Jump to content
dario

Ellipsis on AnyLoop Compact Post Titles

Recommended Posts

dario+    20
dario

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
dario+    20
dario

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
dario+    20
dario

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' );
  • Like 1

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


  • Similar Content

    • tiltcreative
      By tiltcreative
      Hello, I am using anyloop on my home page. I want it to be small and just show the excerpt and title so I've chosen the grid setting. I have tried 300px, 400px, 500px in the 'Post Width (Grid Mode Only)' but it doesn't change. What am I doing wrong?
       
      http://panafricanenergy.com/
       
      Thanks for your help.
    • Frederic
      By Frederic
      Hi Nick,
       
      I am considering buying anyloop and have a few questions re what the section really does:
       
      1- i read you can display post types - does that mean I can have a page/postloop displaying pages instead of posts? And can I select which pages or it would be all of those published?
       
      2- can I have a page/postloop displaying both posts and pages?
       
      3- are you planning a 'popular' or most viewed shorcode for the side bar?
       
      That's it!
       
      THanks for your attention
    • fmwebdesign
      By fmwebdesign
      Hy,
       
      please have a look to our site, we use anyloop on two sites:
      http://www.nms-badaussee.at/news/
       
      and:
      http://www.nms-badaussee.at/unsere-schule/poly/
       
      In the first version there is everything Ok, we want to cut the post´s with the read more (mehr...)
      At the site "poly" we have the same edits, but there is no effect!
       
      What can we do?
      Thanks and best regards
       
    • peters_publishing
      By peters_publishing
      Hello! I'm using Anyloop with Pagelines Framework. I want to paginate the posts that don't appear on the page, but I still want to keep the content area above the posts from Anyloop. Here is a sample page: http://www.skypeenglishclasses.com/english-phrasal-verbs/
×