Archon Digital has created a simple custom template for YARPP that would allow it to display post thumbnails on related posts, similar to how LinkWithin displays relevant articles.
Yesterday, after reading a forum entry on CMF about LinkWithin, I immediately went and installed it on my site just to test and see if it worked as discussed by the forum members. The plugin seemed fine with the only two issues I have is that Linkwithin has a link back to it’s own site and on top of that, it wasn’t being distributed on WordPress.org.
For those of you like me, who are not at ease on using plugins not found on WordPress.org’s repository of open source plugins, Archon Digital created a cutomized template for Yet Another Related Post Plugin or YARPP by mitcho (Michael 芳貴 Erlewine). Since version 3.0, the YARPP plugin allows custom templates as described in this post.
I’ve been using YARPP for such a long time now that I actually just forgot about it and ignored it altogether. All this time I knew there were ways to customize the template and style it with CSS but for some reason, since the plugin just worked well for me, I left it like the way it was when I first installed it.
It seems a major part of what makes the Linkwithin plugin perform so well on blogs is that it displays your related posts along with thumbnails using their own proprietary way of weighing which posts are relevant. To achieve something similar I had to create a template that uses timthumb.php to generate the thumbnails for me using a custom field I am already using extensively on my blog.
Timthumb was an image-resize script created for Mimbo Pro and was eventually released by Darren Hoyt as open source. It is for me one of the best scripts or plugins created to help theme authors to simplify the generation of post thumbnails. Archon Digital uses the timthumb script extensively on this site.
Requirements
- YARPP. In case you haven’t yet, install the plugin YARPP and set the Display options to display using a custom template file as seen on the image below.
- Timthumb. Download the timthumb script. Copy it to your existing theme folder.
- Cache folder. create a folder called cache inside your existing theme folder and set the permissions to 755 or 777 via your ftp software.
- Default image. create an image and save it as default.jpg and upload it to your existing theme folder. This will be the default image in case your post still has no thumbnail assigned to it.
Create a custom PHP file “yarpp-template-post-thumbnail.php”
Copy and paste the following code to notepad or any text editor and the save file as ”yarpp-template-post-thumbnail.php” inside your current theme folder
<?php /*
Example template
Author: Archon Digital (Jonathan Cuevas) http://archondigital.com/
*/
?>
<h3>Possibly Related Posts</h3>
<?php if ($related_query->have_posts()):?>
<ul class="related-posts">
<?php while ($related_query->have_posts()) : $related_query->the_post(); ?>
<li> <?php $postimageurl = get_post_meta($post->ID, 'thumbnail', true); if ($postimageurl) { ?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php echo $postimageurl; ?>&h=100&w=100&zc=1&q=100" alt="<?php the_title(); ?>" width="100" height="100"/></a>
<?php } else { ?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php bloginfo('stylesheet_directory'); ?>/default.jpg&h=100&w=100&zc=1&q=100" alt="<?php the_title(); ?>" width="100" height="100"/></a>
<?php } ?>
<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
<?php else: ?>
<p>No related posts.</p>
<?php endif; ?>
Copy the CSS
Add the following css to your theme’s stylesheet or download text file here.
ul.related-posts {
float: left;
list-style-type: none;
margin: 0px;
padding: 0px;
}
.related-posts li {
list-style-type: none;
float: left;
width: 100px;
padding-right: 8px;
padding-left: 8px;
font-size: 12px;
line-height: 18px;
}
.related-posts img{
width: 100px;
padding: 1px;
border: 1px solid #CCC;
}
Set your YARPP options
Go to your YARPP options panel and follow as illustrated below
Timthumb and custom fields
The template file has refers to a custom field called thumbnail for the timthumb script to work. The thumbnail custom field would require your image’s full URL as its value.
In case you are already using timthumb on your theme then you will only have to edit the template file to match your own custom field. Simply edit the word ‘thumbnail’ on line 9 of the template (see image above).
Still, Linkwithin is a great and effective plugin for bloggers who want a significant improvement on their bounce rates and to those who would want a good related post plugin for WordPress. Definitely, YARPP is better but I think Blogger users would find LinkWithin more useful as it greatly increases the interactivity and it’s very simple to implement.
|
|



















118 Comments
Wow, u r a genius!!
We were just talking about the plugin and u created a template !! Superb !
Follow thepositivelife on Twitter
thanks Raj, though the CSS would need a lot more work. I only had a few minutes of spare time to get this running on my blog.
Follow archondigital on Twitter
Great post Archon! I have existing thumbs in my posts, I think I can use them. I’ll try this later today.
Øyvind´s last blog ..A time traveller?
Follow atrais on Twitter
thanks Øyvind, Let me know how it goes
Follow archondigital on Twitter
Wow, this looks sweet.
Do you have to have a thumbnail for each post already set? or does it generate that for you?
If I get time this weekend, I’ll test it out. Thanks,jb
benwaynet´s last blog ..Stumbling with Not John Chow onto the Trust Train
Follow benwaynet on Twitter
I was already using timthumb.php on my theme to generate post thumbnails and using it on the related posts loop made it much easier as I only have to specify one custom field for all my thumbnails
Follow archondigital on Twitter
Excellent write up!! I am going to try this on some of my sites because Link Within is great, but not having the link go through them would be even better.
Char´s last blog ..Essential Tools Featuring Randa Clay
Follow charpolanosky on Twitter
I’m glad you like it. I personally didn’t like the idea that LinkWithin gets a link back from all my posts.
Follow archondigital on Twitter
thanks for this wonderful idea… I have been using the LinkedWithin plugin but to increase the speed of blog, I have removed it.
Follow a_usman on Twitter
I also noticed that from LinkWithin.
Follow archondigital on Twitter
The custom template file “custom LinkWithin-inspired YARPP template” link doesn’t seem to be valid I can’t download the file. It gives me a 404 on
linkbenwaynet´s last blog ..Bookmarks for March 27th through April 9th
Follow benwaynet on Twitter
thanks Ben, for the heads up.
I fixed the link just “right-click” and “save link as” to be able to get the
yarpp-template-post-thumbnail.php file.
Archon Digital´s last blog ..Why Re-Invent the Wheel? Because Great People Do So.
Follow archondigital on Twitter
Clear my cache and tried a different browser still getting the 404 for
linkthanks,jb
benwaynet´s last blog ..Bookmarks for March 27th through April 9th
Follow benwaynet on Twitter
I revised how you can get the code to avoid the download errors on the php file.
Let me know if you were able to get it working. Thanks.
Follow archondigital on Twitter
Dear Jonathan,
thank you for help!
i used arthemia theme with timthumb
you say – need edit the template file to match your own custom field
i made some post with custom field called “thumbnail_url” and replace “thumbnail”
in yarpp-template-post-thumbnail.php
but still post without thumbnails…
and I just want to clarify ) – YARPP + timthumb allow use first image from post
or anyway need use custom field?
I remember using Arthemia theme with timthumb for testing before and I think it uses the custom field “Image” for thumbnails.
Try using “Image” instead of “thumbnail” in your template file so you can take advantage of the custom field used by Arthemia for thumbnails.
Follow archondigital on Twitter
I love this plugin on my blog, and I never knew that you could customize it to that degree, which should really improve the degree to which my posts are linking within each other. Thanks!
Jimvesting´s last blog ..Jimvesting.com’s New Header Compromise, A Fresh New Look!
Follow jimvesting on Twitter
This is awesome!!! I am not a coder but I would like have this instead of LinkWithin which I have been using for more than a year (looks like they didn’t update my latest thumbs anymore)
I have a few questions:
1. I am not a timthumb user, is it compulsory to save the timthumb.php in my theme folder?
2. My theme comes with a custom fields for me to add the thumbnail’s url at the homepage, can I utilized it?
3. I have done the above, activated YARRP, saved the php for both thumbnail & timthumb in my theme folder, added the CSS and set the YARRP option, everything seems ok just that the thumbnail’s are broken, and no thumbnail appear in Firefox. Can you tell me what didn’t I do correctly?
Thanks!!!!
Craft Passion´s last blog ..Bag Tutorial: Shaggy Bag With Lining
timthumb automates the process of resizing your thumbnails so you won’t have to manually create thumbs for each post.
Make sure you create a folder and name it “cache” on where your put timthumb.php (your theme folder) and set the permissions via ftp to 775 or 777.
You can change the YARPP template file to match the custom field that you are already using for your theme. Timthumb will take care of resizing that for you.
Follow archondigital on Twitter
I’m looking at your site now and I think you need to delete “/style.css” from the path “http://domain.com/wp-content/themes/themename/style.css/timthumb.php”
On the original template file where I put the code
< ?php bloginfo('stylesheet_url'); ?>, you can replace it with “http://domain.com/wp-content/themes/themename/timthumb.php” insteadFollow archondigital on Twitter
do you mean replace the whole phrase of this

/timthumb.phpto this
http://domain.com/wp-content/themes/themename/timthumb.phpCraft Passion´s last blog ..Bag Tutorial: Shaggy Bag With Lining
yes, so instead of this
< ?php bloginfo('stylesheet_url'); ?>/timthumb.phpput
http://domain.com/wp-content/themes/themename/timthumb.phpFollow archondigital on Twitter
Done, but still no thumbnails showing

Craft Passion´s last blog ..Bag Tutorial: Shaggy Bag With Lining
Let me see, I think you are already using something else to resize the thumbnails in your theme.
In that case you no longer have to use timthumb
Change this
< ?php bloginfo('stylesheet_url'); ?>/timthumb.php?src=< ?php echo $postimageurl; ?>&h=100&w=100&zc=1&q=100to this:
< ?php echo $postimageurl; ?>that should do the trick
Follow archondigital on Twitter
errrr excuse me…. both codes look the same, which one should I replace with this ?
Craft Passion´s last blog ..Bag Tutorial: Shaggy Bag With Lining
Change this
< ?php bloginfo('stylesheet_url'); ?>/timthumb.php?src=< ?php echo $postimageurl; ?>&h=100&w=100&zc=1&q=100to just this:
< ?php echo $postimageurl; ?>Follow archondigital on Twitter
That one doesn’t work too, but…… after I change to this (I copied from my theme’s code, it works
I changed this
<a href="” rel=”bookmark” title=”Permanent Link to “><img src="/timthumb.php?src=&h=100&w=100&zc=1&q=100″ alt=” ” width=”100″ height=”100″/>
to this
<a href="” rel=”bookmark”><img style="float:left;margin:0px 10px 0px 0px;" src="ID, “thumbnail”, true); ?>” alt=”" />
Craft Passion´s last blog ..Bag Tutorial: Shaggy Bag With Lining
Thank you so much for such a lovely options!!! You are the BEST!!!!
Now my related post looks so much “related” then using Linkwithin!!! But the draw back is that, by using YARRP, it creates more queries that loaded my hosting server :p
Craft Passion´s last blog ..Bag Tutorial: Shaggy Bag With Lining
Glad to know you got it working.
Follow archondigital on Twitter
Can you remove my url in the above comment, I don’t feel easy with them displaying here. Thanks
I renamed all the link references to generic samples
Follow archondigital on Twitter
Thanks
Looks Good.
I might consider using this but I usually show ads next to Related Posts. With this plugin, I couldn’t anymore.
ProMovieBlogger´s last blog ..The Importance of the Ping and XML-RPC-based Push Mechanisms
Follow ProMovieBlogger on Twitter
by playing around with the CSS you can create something to match your existing design
Follow archondigital on Twitter
I thought about that. If I could stack two on top of two or three on top of three it might work. Is it possible to mod your plugin like that?
ProMovieBlogger´s last blog ..The Importance of the Ping and XML-RPC-based Push Mechanisms
Follow ProMovieBlogger on Twitter
It’s possible to change anything on the CSS, when I have time I’ll create a few more different formats as this one was just something I did quickly after testing that LinkWithin plugin.
and just to make things clear, It is NOT my plugin, I just made a template with thumbnails using timthumb that works for YARPP. The plugin was made by mitcho.
Follow archondigital on Twitter
LinkWithin is becoming more popular and I would like to use it. I show ads in my related posts section. The ad is wrapped around the related posts links that are shown. Currently there is no way to fit both LinkWihin and 300×250 ads in the same section unless (nor can I get LinkWithin to show in my Related Posts section), as I said before, the LinkWithin ads were stacked on top of each other, two on top of two. This might allow enough space for a 300×250 ad to be placed next to it. The LinkWithin script would need to be manual placed in the code next to the wrap script.
Do you think in the near future you will have stacking options of some kind?
ProMovieBlogger´s last blog ..Starting a Movie Website: WordPress Plugins
Follow ProMovieBlogger on Twitter
I’ll see if I can find time over the weekend to create a new template that displays thumbnails vertically in a stack
Follow archondigital on Twitter
Nice one! Just remember that this will add a few more CPU usage though (even if the images have already been cached by the TimThumb script)
Michael Aulia´s last blog ..Unlimited web hosting for $10 a year by Nexx
Follow michaelaulia on Twitter
Since you’ve mentioned it, I’ve been keeping a close eye over CPU usage, bandwidth and RAM and so far there has been a slight increase though it is still minimal and is way below the limitations on my hosting.
Even before it comes to that point I better be sure I find a way to decrease timthumb and YARPP’s CPU consumption.
Thanks for the reminder Michael!
Follow archondigital on Twitter
My hosting guy came back and confirmed that it does increase the server load drastically, but I am not sure if it was caused by this modification or the YARRP itself.

Please help us to look into it. Thanks
Craft Passion´s last blog ..Knitting Pattern: Halterneck Top For Little Girls
probably caused by the YARPP itself. Have you tried using WP-Supercache?
Follow archondigital on Twitter
No, I haven’t. I will forward it to my hosting guy and see if this help to reduce the load.

Thanks
Craft Passion´s last blog ..Knitting Pattern: Halterneck Top For Little Girls
I’ve been looking at some modifications to timthumb to allow better caching and would post something related real soon.
I’d also highly recommend the WP-Supercache plugin to minimize server load increase due to YARPP.
Follow archondigital on Twitter
I tried your template but it didn’t display correctly. When I added the css to style.css still no effect. Where exactly in my css must I put the code?
The Associator´s last blog ..Breves reflexiones acerca del racismo
Follow theassociator on Twitter
can you elaborate exactly what did not display correctly? the CSS style or timthumb?
Follow archondigital on Twitter
Well I followed the exact steps as you mentioned, but when I select the plugin in YARP, it messes up the page design and goes all over the place. Would you care to add me on skype so you can have a look when it is active?
The Associator´s last blog ..Eddie Murphy is on the prowl
Follow theassociator on Twitter
can you try it again? I just updated the template file which you will need to copy again.
Follow archondigital on Twitter
Finally got a chance to give this a try.
But its not working. The site is http://www.benway.net
Most of my posted don’t have thumbnails yet (I tend to host my images not on my site and I haven’t found a easy way to update all my old post with a thumbnail)
So I’m using http://onlinevortex.com/projects/default-postthumbnails/ to use the same image as the default until I get all my old post updated.
Not sure what to look for.
Thanks,jb
benwaynet´s last blog ..Music Monday – The Motions
Follow benwaynet on Twitter
I don’t think timthumb works if the images are hosted externally, I will have to check the documentation on timthumb. I’m also trying to get the built-in thumbnail support from WordPress to work on a test blog so I can create another YARPP template.
Follow archondigital on Twitter
Sorry guys I made a mistake on the template file and I just updated it now.
I replaced all instances of
< ?php bloginfo('stylesheet_url'); ?>and changed it to< ?php bloginfo('template_url'); ?>.I don’t know how that got past me but we’ll I’m only human and I actually hard-coded the location on my own theme.
Follow archondigital on Twitter
Nope, still showing very awkward. It shows no thumbs and messes up the whole page on my site.
Could I send you a screenshot?
The Associator´s last blog ..David Hasselhof is back in Germany
Follow theassociator on Twitter
I sent you an e-mail. We’ll see how I can help you get it setup on your blog.
Follow archondigital on Twitter
Ok test http://www.benway.net/2010/04/19/music-monday-the-motions/
The related post in the middle titled adsense has a thumbnail associated with that post using the wordpress 2.9 select thumbnail not a custom field.
But it still doesn’t show. I also updated the the custom template without luck.
Thank you for all your help.
benwaynet´s last blog ..Music Monday – The Motions
Follow benwaynet on Twitter
I too am wondering about using the WP_Thumbnail ?
I presume it’s as simple as replaceing:
ID, ‘thumbnail’, true); if ($postimageurl) { ?>
with
and dropping the timthumb plug-in. Haven’t tried it yet, will report if/when I do.
It’d also be nice to add a hover color change under the image to the CSS to more closely match linkwithin.
Jon Brown´s last blog ..Hello world!
Follow jb510 on Twitter
I didn’t really spend too much time on the CSS but yes a hover function would be cool.
Right now most my projects use timthumb but in the moment I have a new WordPress installation going I can start using the default thumbnails from WordPress and will probably create another YARPP template for that.
Follow archondigital on Twitter
Hey Archon,
Your YARPP style is *exactly* what I want to have on my blog, but unfortunately, I seem to have missed something.
Take a look at http://techhaze.com/2010/04/mac-app-transmit-4/ for instance. I think it has something to do with the CSS. I copied
ul.related-posts {float: left;
list-style-type: none;
margin: 0px;
padding: 0px;
}
.related-posts li {
list-style-type: none;
float: left;
width: 100px;
padding-right: 8px;
padding-left: 8px;
font-size: 12px;
line-height: 18px;
}
.related-posts img{
width: 100px;
padding: 1px;
border: 1px solid #CCC;
}
to my stylesheet.css, but I’m still showing very weird bullet points etc…
Any help is greatly appreciated!
Florian Wardell´s last blog ..Mac app: Transmit 4
Follow techhaze on Twitter
I am looking at your site now seems the generic YARPP template is in use. Have you set your YARPP configuration to use the template under Display options?
Follow archondigital on Twitter
Hey Archon,
Thanks for your quick response. I disabled the template cause it looked kinda bad. It should be enabled again now.
Follow techhaze on Twitter
Ok, I worked on it a little bit.
I have this php
Related Postshave_posts()):?>
have_posts()) : $related_query->the_post(); ?>
ID, 'Thumbnail', true); if ($postimageurl) { ?>
<a href="" rel="bookmark" title="Permanent Link to "><img src="/timthumb.php?src=&h=100&w=100&zc=1&q=100" alt="" width="100" height="100"/>
<a href="" rel="bookmark" title="Permanent Link to "><img src="/timthumb.php?src=/default.jpg&h=100&w=100&zc=1&q=100" alt="" width="100" height="100"/>
<a href="" rel="bookmark">
No related posts.
and this style
ul.related-posts {
float: left;
list-style-type: none;
margin: 0px;
padding: 0px;
border: 6px solid #e8e8e8;
list-style-image: none;
}
.related-posts li {
list-style-type: none;
float: left;
width: 120px;
padding-right: 8px;
padding-left: 8px;
font-size: 12px;
line-height: 18px;
margin-top: 13px;
border-left: 1px solid #e8e8e8;
list-style-image: none;
}
.related-posts img{
width: 100px;
padding: 1px;
border: 1px solid #CCC;
list-style-image: none;
list-style-type: none;
}
and yet I still get bullet points. The only way to remove them is to put “disc” to “none” in
.post ul li { list-style-position: inside; list-style-type: disc; line-height: 24px }but this would also remove the bullet points from my paragraph, where I actually need them. Any help is greatly appreciated!
Florian Wardell´s last blog ..Mac app: Transmit 4
Follow techhaze on Twitter
Try changing this on the style sheet
.related-posts lito this
.post ul li.related-postsHope that works
Follow archondigital on Twitter
YARPP is an amazing plugin and I use it on all my blogs. I will look into changing the templates of it in a short while. Never bothered much about customizing it because it just did what I wanted it to do i.e. Show related posts that’s all haha..
Kamal Hasa´s last blog ..YARPP – Yet Another Related Posts Plugin – WordPress
Follow NPXPcom on Twitter
Been using it for years but I entirely forgot about it because the plugin just works and I never had any issues.
Follow archondigital on Twitter
I am playing around with this.
The only problem is mine won’t – no matter what I’ve tried so far – display a thumbnail.
Is there anything I need to add to theme functions or timthumb script or elsewhere for the image to display?
Thanks.
Mark´s last blog ..Secret Knock Lock = Awesome
Follow techiezine on Twitter
I can help you out if you could be more specific and share more details
Follow archondigital on Twitter
I had no idea what I was doing whatsoever but eventually I was able to get it working.
I took some code from the “related posts by category” plugin then added it into the YARPP plugin files.
Then used my dp_attatchement_image function to auto generate the thumbnails.
Was a painstaking few hours to begin with but a fresh wakening in the morning gave me the energy and brainpower needed to figure out a way to do it.
I always wonder how I manage to do these things even though I have only half an idea. I guess it’s down to guys like you who provide methods that we can all learn from even if they don’t fully work out.
Thanks.
Follow techiezine on Twitter
Funnily I ended upcreating so may templates that in the end the tempalte eneded up ending in the word fart3.php
Shows how much I went through to end up putting that on the end.
Follow techiezine on Twitter
LOL! Nice to know you got it after fart3.php otherwise God knows what filename you’d end up with.
Funny, I also tend to get to solve more technical problems right after sleeping through them.
Follow archondigital on Twitter
Many many thanks, i was trying to do it myself but couldn’t work it out, you’re heaven sent!
Sory guys, this is not working for me… I managed to get at least the default thumbnail, but can’t get the proper one.
The problem seems to be with my scarce understanding of the
$postimageurl = get_post_meta($post->ID, ‘thumbnail’, true);
…I don’t see that custom meta being generated anywhere, I thought timthumb should generate it, but apparently it does not
Any help would be appreciated!!
F.
forgot to mention that I do get randomly named png files in my cache folder (example: 0f547bd3d5fa0469a777716ecb7275be.png), but they all look the same as the default one, plus they are really jpg file with a wrong extension, and anyway they do not get used on my template.
I know it because I overwrote my original default.jpg (grey) with a new one (violet) and my website displays the violet one, while 0f547bd3d5fa0469a777716ecb7275be.png is still a copy of the grey one, so if it was being used I should see at least one grey thumbnail… not sure if this is of any help, but I just thought to write as much info as possible!
Seems it’s working fine and you only have to edit your posts and create a custom field called thumbnail. The value of which should be the URL of the image you want to use.
For example on your most recent post, you should create a custom field with the name thumbnail and the value of
http://lh6.ggpht.com/_lqT3Pk7g-PM/S_H6TKeweHI/AAAAAAAAAsg/K8rCDE2R6bc/diesel2.jpgSee it working by clicking below:
http://lilacandyellow.com/wp-content/themes/simple-type/timthumb.php?src=http://lh6.ggpht.com/_lqT3Pk7g-PM/S_H6TKeweHI/AAAAAAAAAsg/K8rCDE2R6bc/diesel2.jpg&h=100&w=100&zc=1&q=100Take note make sure the URL you put does not have anything else after .jpg as it will cause timthumb to display an error message.
Follow archondigital on Twitter
yes, I had to change a bit of the code…
in yarpp-template-post-thumbnail.php
/timthumb.php?src=/cache/default.jpg
and in timthumb.php had to add ggpth.com as an allowed source, plus add a preg_replace to remove ?imgmax=xxx from the url.
But I thought timthumb.php would automatically create a thumbnail… is there any way to automate that step? I thought I read somewhere timthumb will use the first image of the post automatically?
I am going nut… I found something to automatically generate posts, but it only work in the_loop, I don’t know how to parse images from
while ($related_query->have_posts()) : $related_query->the_post();
Will post it if I find a solution
I think I got it!!!
I changed the “else” statement in yarpp-template:
else {
$output = preg_match_all(‘//i’, $post->post_content, $matches);
if ($matches [1] [0]) { $first_img = $matches [1] [0];
} else { $first_img = ‘./cache/default.jpg’; }
?>
<a href="” rel=”bookmark” title=”"><img src="/timthumb.php?src=&h=100&w=100&zc=1&q=100″ alt=”" width=”100″ height=”100″/>
plus added another str_replace in timthumb (replacing ” ” with “%20″).
I think it works now… I believe it could be a nice feature to add in the original script: basically it relieves the user from manually creating the thumbnail custom field!
Thanks for the template, it’s awesome
Ah that’[s great.
Though I will say that no matter how may times I’ve ever tried to use the ”thumbnail’ call I’ve never gotten it to work.
I’ve realized now that the best option is using the wp_get_attatchment_image with a databse query for the relevant posts.
Works like a charm and always uses less code than these other ways.
However that function doesn’t seem to be talked about much on the web which to me is confusing as I think it’s an awesome fucntion in comparison the most of the options including timthumb. As timthumb actually creates errors on the page too.
Follow techiezine on Twitter
This is great. We’ll be implementing this same related post template on our upcoming blog
Follow brooklandsGB on Twitter
Hey – thanks for voicing your opinion about the “Link Within” plugin. I have heard a few reviews now but yours is the most in depth. I have never used a plugin that hasn’t been in the WordPress.org site before – this one could very well be the first!
Ali @ Hannibal Costumes´s last blog ..About Us
Some one refer me to this site and find this post what I need and now using this I can add thumbnail in my related post
Hi,
thanks for this unique tut. but im kinda having a hard time implenting it. nothing will appear if i leave “Automatically display related posts” unchecked. and if its checked it will only show the
url. no thumbnail.
Im currently using aparatus theme. sorry, im kinda new to this.
cheers,
As others have mentioned, great post Archon Digital!
I like seeing how someone takes something that already exists, and expands upon it’s functionality.
I actually came across your article here searching for ways people are adding images to their related posts. I use a different plugin myself (for now at least), but it’s based on the same concept and I’ve modified it a bit myself.
One thing I would like to mention in case anyone is interested, is if they’d like a “hover effect” when someone mouses over their images in the related posts box. You can see how I’m using this on my site(s). I’ve added the following css to mine (I added the class you are using in your article here):
.related-posts a img:hover {
filter:alpha(opacity=50);
-moz-opacity:0.5;
-khtml-opacity: 0.5;
opacity: 0.5;
}
Just use the class or id of the related post image you are using. The opacity limits can be played around with as well to get your desired look.
Larry´s last blog ..AC-DC Video – Thunderstruck – Live at Donnington 1991
thanks for the tip
Follow archondigital on Twitter
Hey, i am the admin of pastisold.com.Thank’s for sharing this information.This is very helpful and informative material.Good post and keep it up dude.
You’re welcome and thanks for the visit
Follow archondigital on Twitter
Hi
Could you, please tell me where can I get your complete yarpp-template-post-thumbnail.php file? There is no download link like for .css and the stuff that is available to copy is not php. I can only select and copy this:
Possibly Related Posts
have_posts()):?>
have_posts()) : $related_query->the_post(); ?>
ID, ‘thumbnail’, true); if ($postimageurl) { ?>
No related posts.
But this is incomplete code… Maybe I’m missing a download link for a full version.
I’m using timthumb and would really like to combine it with yarpp. Thank you for your help.
Z
Follow ArtZoran on Twitter
You should be able to properly copy the code now. I changed my syntax plugin and fixed the code snippets. They must’ve got broken after upgrading to WP 3.0.
Follow archondigital on Twitter
Hi
Thank you for the reply and the changes but, unfortunately, the code isn’t correct again. Your code shows the “>” as “>” and “<" as "<". I believe it shouldn't be converting the code to html entities because I've checked other yarpp templates and they have no html entities inside.
Also, shoudn't here be:
"have_posts()):?>”
instead of:
have_posts()):?>
I’m a designer myself, not fluent in php but I still believe something is not right with the code. Please assist again if possible?
Thanks and best wishes
Z
Follow ArtZoran on Twitter
Hi
Thank you for the reply and the changes but, unfortunately, the code isn’t correct again. Your code shows the “>” as “>” and “<" as "<". I believe it shouldn't be converting the code to html entities because I've checked other yarpp templates and they have no html entities inside.
Also, shoudn't here be:
"have_posts()):?>”
instead of:
have_posts()):?>
I’m a designer myself, not fluent in php but I still believe something is not right with the code. Please assist again if possible? I’d love to make this thing work because I already have timthumb and this looks like a better solution than “Related Posts Thumbnail” plugin which is going to be the alternative if I’m not going to make yarpp work.
Thanks and best wishes
Z
Follow ArtZoran on Twitter
Sorry for multiple posts but this part was converted without the quotes around:
Other yarpp templates have this:
“have_posts()):?>”
And your code looks like this:
“have_posts()):?>”
Besides, your screenshot shows other considerable differences in code compared to the code you offered for copying.
On a side note, I wish you have “Preview posts” and “Edit posts” options here on your page. It would help a lot. I could manage everything in one post intead of three
Thanks again for your time.
Z
Follow ArtZoran on Twitter
Try it again, I just fixed the code again.
Follow archondigital on Twitter
Finally got it working, but only after replacing some html entities again. I compared it to the other pages where I have timthumb and noticed some differences. For instance…
My timthumb:
“zc=1&q=70″
Your timthumb:
“zc=1&q=70
Notice the absence of “amp” in your version. I’ve corrected this in eight instances alltogether. Now I’m having tumbnails but they are all scattered around, probably have to get css in order. Something with the span class. If you’d like, you can check it out on my blog, just view any single post…
Oh, yes, I also had to check the option “Automatically display related posts” in order for thumbnails to be displayed.
Thank you again for a great enhancement to YARPP and for a prompt response regarding the problem.
All the best.
Z
Follow ArtZoran on Twitter
Well, it’s me again
You can’t notice the absence of “amp” in my previous post because it was automatically converted
Just look at your code and you’ll see what I mean.
Best
Z
Follow ArtZoran on Twitter
Got it right, finally…
Thanks again.
Z
Follow ArtZoran on Twitter
glad to know you got it sorted
Follow archondigital on Twitter
I would like to use your plugin in the main index and the main index only on my website, like here: http://theplaylist.blogspot.com/ Is that possible with what you have made. If so, what are the steps?
ProMovieBlogger´s last blog ..Movie Website In-Text Advertising- Infolinks Review
Follow ProMovieBlogger on Twitter
I don’t think YARPP works on Blogger but you can use LinkWithin for that
Follow archondigital on Twitter
nrelate is another alternative with awesome looking thumbnails! It works like linkwithin, where all the logic is done on the nrelate server. The plugin is a simple 1-click install and is on WordPress.org http://wordpress.org/extend/plugins/nrelate-related-content/
Highly recommended.
Hey thanks for the info, I’ll check out this plug-in you just posted
Follow archondigital on Twitter
Hi,
First of all, thanks very much. I added LinkWithin this morning to test, but was not happy with the URL redirect every time a related post was added, so have opted for YARPP. After a little searching I found your very useful code.
I am, however, having some issues with this – the thumbnails do not seem to be being generated (as you can see on any of the posts. I am using the ‘TheMorningAfter’ theme by WooThemes, and they seem to already use timthumb in a file called thumb.php. I have tried renaming all instances of timthumb.php to thumb.php but this has not worked. I think it might be that the field name is different in thumb.php, but am not sure how to find it.
Are you able to help?
Chris
Chris´s last blog ..Update- Doktor A’s GNOME design pictures
Follow yellowbearvinyl on Twitter
I don’t think thumb.php and timthumb.php are the same but Woothemes does have a lot of support documentation for the structure of that particular theme.
Follow archondigital on Twitter
I’ll have another look at WooThemes, but unfortunately this is one of there free themes, and their support forums are only available if you are a paid subscriber, which I currently am not.
Thumb.php opens with:
TimThumb script created by Tim McDaniels and Darren Hoyt with tweaks by Ben Gillbanks
http://code.google.com/p/timthumb/
so it looks like it is TimThumb. It doesn’t seem to be generating any thumbnails of images uploading now, or previously.
Chris
Chris´s last blog ..Don’t Believe The Hype!
Follow yellowbearvinyl on Twitter
Hey Chris– you may want to try nrelate’s new related content plugin. It works similarly to linkwithin without the redirects, and looks better than YARPP. 1-click install and you’re ready to go. Plus, we really want to work with bloggers and appreciate all feedback.
You can check out the plugin here:
http://wordpress.org/extend/plugins/nrelate-related-content/
I have looked into this further. The custom name for the image seems to be ‘woo_image’, and the php call for it is woo_get_image (I think!).
I have added both of these as follows, but have not yet had any luck:
<?php /*
Example template
Author: Archon Digital (Jonathan Cuevas) http://archondigital.com/
*/
?>
You might also like:
have_posts()):?>
have_posts()) : $related_query->the_post(); woo_get_image(array(100,100)); ?>
ID, 'woo_image', true); if ($postimageurl) { ?>
<a href="" rel="bookmark" title=""><img src="/thumb.php?src=&h=100&w=100&zc=1&q=100" alt="" width="100" height="100"/>
<a href="" rel="bookmark" title=""><img src="/thumb.php?src=/default.jpg&h=100&w=100&zc=1&q=100" alt="" width="100" height="100"/>
<a href="" rel="bookmark">
No related posts.
Any ideas?
Chris´s last blog ..My Tummy Toys Clear Jouwe Digi Wings Breeze
Follow yellowbearvinyl on Twitter
Hello Archon,
I think you’ve done a great work with your template. I tried it on a blog that I’m running since last year, and got to a problem that maybe someone here has already figured out: none of my old posts have the thumbnail custom field. The new ones may have the Featured Image, but what should I do with 2000 old images?
You can see it here: ffffuuuud.eu.
It’s a template I’ve been working to show related funny images.
Do you have any clues?
thanks in advance,
Tarrask
Follow tarrask on Twitter
there should be a way to have it pick up the 1st image in a post but I haven’t tried that yet
Follow archondigital on Twitter
This is brilliant, such a great tutorial.
My theme uses “featured image” by default and there’s no custom field used. In the media library there is a button on the bottom which reads “Use as featured image”… however that makes no use of custom field as i said. do you know how to adapt so it will get the thumbnail from the featured image? if thats possible?
Thank you very much
Hey, that’s a nice tut, I have further expand this tut into diffrent idea, show related posts in a list with thumb side by side. check my post at http://www.alivethemes.com/how-to-create-style-related-posts-using-yarpp-plugin/
Excellent tutorial buddy.
Just started using YARPP myselve
used LinkWithin which did work great (used css to hide the link)
but didnt like how the clicks on links within were being shown within analytics.
So got rid of it (although it does work great)
I’m on a dedicated server so using YARPP isnt really a issue and i’ve nto see any major differences with CPU usage or anything at the moment – I am also using a caching plugin
I’m currently just using the default method of showing related posts but would love to use the same template as with linked within but for me to do this I would really luike a way to have the image coming from the first image within a post if one exists (very much the same way in which linkedwithin worked)
is it possible to do this yet?
For those of you asking about getting it to work with the WP 2.9+ “featured image” functionality – here is what worked for me:
have_posts()) : $related_query->the_post(); ?>
<a href="” rel=”bookmark” title=”Permanent Link to “>
<a href="” rel=”bookmark”>
I used the function the_post_thumbnail() with a custom image size of 120×120 in this case. All my posts have the featured image thumbnails, but if you needed to do some detection, there is another function called has_post_thumbnail() that could be used.
Wood Flooring´s last blog ..Unfinished Hardwood Floors Have Unique Advantages
Oops, most of my code got parsed out of that last comment. Anyway, put this inside the “while ($related_query->have_posts()) ” loop:
the_post_thumbnail(array(100,100));
It will render your Featured Image thumbnail for each post at the dimensions specified in the array.
Wood Flooring´s last blog ..Unfinished Hardwood Floors Have Unique Advantages
@Wood Flooring
Can you please give me more details on how to adapt the given code? I tried to do it but it doesnt work :S , where exactly i have to place the “the_post_thumbnail(array(100,100)); ” code ?
Best
Let me try nesting it in the code tags:
Related Articles:
have_posts()):?>
have_posts()) : $related_query->the_post(); ?>
<a href="" rel="bookmark" title="Permanent Link to ">
<a href="" rel="bookmark">
No related posts.
that didn’t work. let me try replacing greater than/less than symbols with square brackets…
[h3]Related Articles:[/h3]
[?php if ($related_query-]have_posts()):?]
[ul class="related-posts"]
[?php while ($related_query-]have_posts()) : $related_query-]the_post(); ?]
[li]
[a href="[?php the_permalink(); ?]" rel="bookmark" title="Permanent Link to [?php the_title(); ?]"][?php the_post_thumbnail(array(120,120)); ?][/a]
[a href="[?php the_permalink() ?]" rel="bookmark"][?php the_title(); ?][/a]
[/li]
[?php endwhile; ?]
[/ul]
[?php else: ?]
[p]No related posts.[/p]
[?php endif; ?]
Hi,
I have been able to get the thumbnails working, but they are showing separately to the related posts. I can see 5 related posts with the post title below, and 5 thumbnails next to them.
Any ideas?
Chris´s last blog ..My Tummy Toys Clear Jouwe Digi Wings Breeze
Follow yellowbearvinyl on Twitter
So, I managed to get this to work. The problem was this – I have been using the media uploader to insert images, and it is not storing it in the post using the image fields (I think).
Anyway, I used the code below (written by a friend) to pull the image out using
” $output = preg_match_all(‘//i’, do_shortcode(‘[gallery]‘) . $post->post_content, $matches); ”
to pull the content from the post and grab the image.
This took me quite a while, and someone who can code a lot better than I, to sort this. Hopefully this will be of some use to others who had the problem I did:
function get_first_image()
{
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('//i', do_shortcode('[gallery]') . $post->post_content, $matches);
$first_img = $matches [1] [0];
//echo "";
//echo "";
//echo "";
if(empty($first_img)){ //Defines a default image
$first_img = false;
}
return $first_img;
}
?>
Thanks again Archon. This looks as good as LinkWithin, and gives me the far better matching capabilities of YARPP, with the extra control.
Thank you.
Chris´s last blog ..Tomorrow Queen Reimi by 3A Toys
Follow yellowbearvinyl on Twitter
It’s a very good use of YARPP template, thanks for sharing this. I also made a similar effort about YARPP template, but leveraging only the post-thumbnail feature of WordPress 2.9. I wrote my implementation details here: http://suhanto.net/yarpp-template-post-thumbnails/.
Thanks again for sharing.
Agus Suhanto´s last blog ..YARPP Template with Post-Thumbnails
Sports Pilipinas News Update Online
watch pba,nba,boxing,manny pacquioa,smartgilas,ufc,james yap,online news,kobe bryant,lebron james,dwyne wade,nonito donaire,online streaming free
http://www.sportspilipinas.info/
Hello,
I get bullet before the thumbnails. I have tried the solution you propose in the answer to Florian but it didn’t work for me. Any suggestion??
By the way, I have had also many problems showing the thumbnails and I finally used the way the get the thumbnail here http://www.alivethemes.com/how-to-create-style-related-posts-using-yarpp-plugin/ and combining it with your css linkwithin-alike.
Thanks for your work
Comparativa de Bancos de México´s last blog ..Cuenta Max de Caja Laboral
22 Trackbacks
RT @archondigital: LinkWithin – inspired YARPP Template http://bit.ly/cnuVer
RT @archondigital: LinkWithin-Inspired YARPP Template http://bit.ly/cnuVer vote for it over @blogengage #blogengage #networking #social
RT @archondigital: LinkWithin-Inspired YARPP Template http://bit.ly/cnuVer
[...] those of you running the YARPP wordpress plugin, Archon Digital wrote a sweet template for it that I’m going to try on this site this weekend. Once I get it [...]
RT @archondigital: LinkWithin-Inspired YARPP Template http://bit.ly/cnuVer
[...] linkwithin inspired yarpp template – Archon Digital has created a simple custom template for YARPP that would allow it to display post thumbnails on related posts, similar to how LinkWithin displays relevant articles. [...]
RT @archondigital: LinkWithin-Inspired YARPP Template http://bit.ly/cnuVer
[...] thumbnails using timthumb. This is after a day of tinkering with LinkWithin. Read more of it here YARPP Template using Timthumb for Thumbnails [...]
A YARPP template which uses Timthumb for better post thumbnails! http://tinyurl.com/39pp76l
RT @yarpp: A YARPP template which uses Timthumb for better post thumbnails! http://tinyurl.com/39pp76l #wordpress
RT @yarpp: A YARPP template which uses Timthumb for better post thumbnails! http://tinyurl.com/39pp76l #wordpress /via @themelab
http://archondigital.com/studio/wordpress/plugins/linkwithin-inspired-yarpp-template/
[...] relación a los thumbnails, las plantillas en los tutoriales que encontré toman las miniaturas de los “custom fields” pero en la siguiente plantilla además de [...]
LinkWithin-Inspired YARPP Template http://su.pr/A6oo7G
LinkWithin-Inspired YARPP Template using Timthumb http://su.pr/A6oo7G
Timthumb powered YARPP Template with thumbnails http://su.pr/A6oo7G
code snippet fixed! – LinkWithin-Inspired YARPP Template http://bit.ly/cnuVer
[...] Once named by Matt Cuts as the best related Post Plugin around. Yet Another Related Posts Plugin (YARPP) gives you a list of posts and/or pages related to the current entry, introducing the reader to other relevant content on your site. Currently I use a modified version of YARRP that pulls thumbnail images for my related posts. You can find the tutorial on how I made that happen here. [...]
[...] YARPP也能提供类似功能(LinkWithin-Inspired YARPP Template),不过要稍显麻烦些,需要一个Timthumb的脚本,以便生成缩略图 LinkWithin的Related posts with thumbnails功能截图 [...]
RT @archondigital: LinkWithin-Inspired YARPP Template http://bit.ly/cnuVer
[...] you do decide to go with YARPP, you may find this template particularly useful for mimicking LinkWithin using the plugin. AKPC_IDS += "14509,"; Written by [...]
LinkWithin-Inspired YARPP Template – http://archondigital.com/studio/wordpress/plugins/linkwithin-inspired-yarpp-template/