-
AuthorPosts
-
May 31, 2015 at 2:29 pm #287813
TsavoParticipantHey guys,
How can I configure WordPress/X Theme to truncate post titles automatically if they are over 25 words? I want to have some sort of (…More) link pop up to the post when post titles are over 25 words.
Thanks!
May 31, 2015 at 11:33 pm #288163
Rue NelModeratorHello There,
Thanks for posting in!
To truncate post titles automatically, please add the following css code in the customizer, Appearance > Customize > Custom > CSS or insert this code in your child theme’s style.css (if you are using a child theme)
.hentry .entry-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }Using css will not allow you to determine if it is already over 25 characters. The css will only check if the characters is beyond the borders of the container element. You will need a js script if you want the title to adjust to a precise number of words. Please try looking for a plugin that may help you.
If you want to adjust the except length of your excerpt, you can set it in the customizer, Appearance > Customize > Blog > Content > Excerpt Length
Hope this helps. Kindly let us know.
June 1, 2015 at 9:59 pm #289313
TsavoParticipantBy “plugin” do you mean custom CSS in JavaScript section? Or an actual WordPress plugin?
Does the “excerpt length” section in the customizer apply to both the post content and title? It doesn’t seem to change anything when I input a number.
Thanks!
June 2, 2015 at 1:07 pm #290047
NicoModeratorHi There,
In regards to the excerpt length, Would you mind sharing us your admin credentials so we could check your current setup.
Don’t forget to set it as private reply.
Thank you so much.
June 2, 2015 at 3:43 pm #290245
TsavoParticipantThis reply has been marked as private.June 3, 2015 at 7:41 am #290904
ChristopherModeratorHi there,
#1 Please remove following code from Customize -> custom -> JavaScript :
.wpcf7 input[type="text"], .wpcf7 input[type="email"], .wpcf7 textarea { border: 1px solid #d3d3d3; border-radius: 3px; padding: 0px 0; }And put it in CSS section.
#2 I searched for provide post title and the result didn’t show that specific post.
http://loglineit.com/wp-admin/edit.php?s=loglines&post_status=all&post_type=post&action=-1&m=0&cat=0&seo_filter&paged=1&mode=list&action2=-1But upon checking some posts I see you added only a few words like two words in posts, so increase your content on these posts and test again.
Hope it helps.
June 3, 2015 at 12:33 pm #291234
TsavoParticipantSorry, I don’t know if I was being clear enough.
Each post on my site will have little to no words in the post content, as the post titles themselves ARE the content. So what is contained inside the post does not need to be truncated, but rather the post title only.
I tried out the excerpt length and it does indeed work correctly, albeit for the post content and not the title. I just want to figure out a way to truncate only the post titles if they are > 25 words.
Is this possible with a WordPress plugin? JS script in the customizer? Or perhaps some custom CSS?
Thanks!
June 3, 2015 at 6:43 pm #291804
RadModeratorHi there,
Thanks for writing in.
Excerpt length is only applicable for excerpts. Perhaps, you can try this out.
Add this code at your child theme’s functions.php
function limited_title ( $post_title ) { $post_title = explode(' ', $post_title , 25 ); if ( count( $post_title )>= 25 ) { array_pop( $post_title ); $post_title = implode( " " , $post_title).'.'; } else { $post_title = implode( " " , $post_title ); } $post_title = preg_replace('<code>\[[^\]]*\]</code>','', $post_title ); return $post_title; } add_filter( 'the_title', 'limited_title', 9999 );Hope this helps.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-287813 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
