Related Posts seem to be properly displayed on my end:
http://i.wpne.ws/W7zM
If you still experience issues, could you try in a different browser, and let me know if your problem is browser-specific?
Thanks!
Hi Jeremy,
I repaired it yesterday. The problem was that, in Jetpack Related Posts module, while showing more than 3 related articles, if the post title is long then it will end up being displayed like this: http://worldanimeclub.com/wp-content/uploads/2014/06/jetpack.png
I corrected it by using the code below, such that if a post title length is more than 27 characters then the remaining characters of the title will be stripped down. This will preserve the layout of the related posts for 6 or more items.
protected function _get_title( $post_title, $post_content ) {
if ( ! empty( $post_title ) ){
$post_title = substr($post_title, 0, 27);
$post_title = $post_title.'.....';
return $post_title;
}
Hi Rahul,
Could you please tell me exactly where you placed your fix as I am getting the same problem.
I tried placing it in the function.php but it crashed my site, if you could let me know the exact place that would be great.
Thanks
Hi, you should find the code
/**
* Returns either the title or a small excerpt to use as title for post.
*
* @param string $post_title
* @param string $post_content
* @uses strip_shortcodes, wp_trim_words, __
* @return string
*/
in wp-content/plugins/jetpack/modules/related-posts/jetpack-related-posts.php
then you should replace all the code under it with
protected function _get_title( $post_title, $post_content ) {
if ( ! empty( $post_title ) ){
$post_title = substr($post_title, 0, 27);
$post_title = $post_title.'.....';
return $post_title;
}
return __( 'Untitled Post', 'jetpack' );
}
leave the remaininf code, starting from
/**
* Returns a plain text post excerpt for title attribute of links.............
untouched
Sorry, that was a little confusing, it will be better explained like this
Original Code:
protected function _get_title( $post_title, $post_content ) {
if ( ! empty( $post_title ) )
return $post_title;
$post_title = wp_trim_words( strip_shortcodes( $post_content ), 5 );
if ( ! empty( $post_title ) )
return $post_title;
return __( 'Untitled Post', 'jetpack' );
}
Replaced Code:
protected function _get_title( $post_title, $post_content ) {
if ( ! empty( $post_title ) ){
$post_title = substr($post_title, 0, 27);
$post_title = $post_title.'.....';
return $post_title;
}
$post_title = wp_trim_words( $post_title, 3, '...' );
if ( ! empty( $post_title ) )
return $post_title;
return __( 'Untitled Post', 'jetpack' );
}
Thanks Rahul,
The code worked perfectly. I noticed however the the title is also trimmed from the tooltip when you hover over the thumbnails.
Have you found a way to fix this?
I also found a plugin called shareaholic that looked similar to the Jetpack related posts I may give that a try.
@j33 let us know if we can answer any questions reg. Shareaholic.
@j33, well I use Jetpack for most my needs because I can stay close to original WordPress as much as possible and Jetpack related posts will reduce server load since it is handled by WordPress.com servers.
Ya, Shareaholic is also good. But do not bother much about Related Posts, their main purpose is to reduce bounce rates, so just make sure you display at least 6 related articles under a post.
Thanks for all your help Rahul.
Hey shareaholic, I haven’t tried out your plugin yet but will do so soon and if it works out better than the Jetpack related posts I will be happy to keep it on my site.
This is my site if you are interested: Travel on Inspiration
@j33 You should give it a shot. You may be pleasantly surprised π btw, your site looks great!
Case studies: https://blog.shareaholic.com/the-definitive-guide-to-related-content-ebook/ * More info: https://shareaholic.com/publishers/recommendations/
@rahul Shareaholic also does all the computations on its servers – keeping your server load to a minimal.
I don’t want to hijack this thread. If you guys have additional questions, please feel free to email me directly! jay at shareaholic dot com
Hi there, @rahul, having same problem with mobile devices here.
Your code works π but π
1. I am getting back tooo many dots after the title text
http://prntscr.com/4hkzbx.
2. In case of really long titles, the code makes the title vanish and become ‘Null’ http://prntscr.com/4hkzpo
Any idea?
Thanks!
That’s indeed something we need to look at in Jetpack. I created an issue in our bug tracker, and you can follow our progress here:
https://github.com/Automattic/jetpack/issues/1091
Thanks Jeremy, I will follow your sure successfull progress.
Jesus