LinkWithin-Inspired YARPP Template

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.

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.

A sample of how the custom YARPP template looks

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.



Smashing WordPress: Beyond the Blog (Kindle Edition)

By (author) Thord Daniel Hedengren

List Price: $44.99 USD
Release date February 4, 2010.

Share and Enjoy

  • Digg
  • Twitter
  • Facebook
  • del.icio.us
  • StumbleUpon
  • Reddit
This entry was posted in Plugins and tagged , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

118 Comments

  1. Posted March 31, 2010 at 3:59 pm | Permalink

    Wow, u r a genius!!

    We were just talking about the plugin and u created a template !! Superb !

    • Posted March 31, 2010 at 5:23 pm | Permalink

      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.

  2. Posted March 31, 2010 at 7:09 pm | Permalink

    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? My ComLuv Profile

  3. Posted March 31, 2010 at 10:18 pm | Permalink

    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 My ComLuv Profile

    • Posted April 1, 2010 at 2:12 am | Permalink

      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

  4. Posted April 1, 2010 at 8:20 am | Permalink

    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 My ComLuv Profile

    • Posted April 1, 2010 at 4:08 pm | Permalink

      I’m glad you like it. I personally didn’t like the idea that LinkWithin gets a link back from all my posts.

  5. Posted April 7, 2010 at 4:07 pm | Permalink

    thanks for this wonderful idea… I have been using the LinkedWithin plugin but to increase the speed of blog, I have removed it.

  6. Posted April 12, 2010 at 8:36 am | Permalink

    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 link
    benwaynet´s last blog ..Bookmarks for March 27th through April 9th My ComLuv Profile

  7. Posted April 12, 2010 at 9:45 am | Permalink

    Clear my cache and tried a different browser still getting the 404 for
    link

    thanks,jb
    benwaynet´s last blog ..Bookmarks for March 27th through April 9th My ComLuv Profile

    • Posted April 13, 2010 at 1:43 am | Permalink

      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.

  8. Valery
    Posted April 13, 2010 at 10:17 pm | Permalink

    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?

    • Posted April 13, 2010 at 11:12 pm | Permalink

      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.

  9. Posted April 14, 2010 at 7:07 am | Permalink

    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! My ComLuv Profile

  10. Posted April 14, 2010 at 1:54 pm | Permalink

    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 My ComLuv Profile

    • Posted April 14, 2010 at 3:08 pm | Permalink

      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.

    • Posted April 14, 2010 at 3:24 pm | Permalink

      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” instead

  11. Posted April 14, 2010 at 3:42 pm | Permalink

    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 My ComLuv Profile

    • Posted April 14, 2010 at 3:56 pm | Permalink

      by playing around with the CSS you can create something to match your existing design

      • Posted April 15, 2010 at 1:17 pm | Permalink

        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 My ComLuv Profile

        • Posted April 15, 2010 at 4:47 pm | Permalink

          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.

      • Posted May 18, 2010 at 11:50 am | Permalink

        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 My ComLuv Profile

        • Posted May 20, 2010 at 4:33 am | Permalink

          I’ll see if I can find time over the weekend to create a new template that displays thumbnails vertically in a stack

  12. Posted April 16, 2010 at 10:13 am | Permalink

    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 My ComLuv Profile

    • Posted April 16, 2010 at 5:40 pm | Permalink

      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!

    • Posted April 19, 2010 at 6:13 pm | Permalink

      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.

  13. Posted April 22, 2010 at 6:46 pm | Permalink

    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 My ComLuv Profile

    • Posted April 22, 2010 at 10:51 pm | Permalink

      can you elaborate exactly what did not display correctly? the CSS style or timthumb?

      • Posted April 23, 2010 at 1:14 am | Permalink

        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 My ComLuv Profile

        • Posted April 24, 2010 at 2:53 pm | Permalink

          can you try it again? I just updated the template file which you will need to copy again.

  14. Posted April 24, 2010 at 11:15 am | Permalink

    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 My ComLuv Profile

    • Posted April 24, 2010 at 2:23 pm | Permalink

      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.

  15. Posted April 24, 2010 at 2:34 pm | Permalink

    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.

  16. Posted April 24, 2010 at 8:21 pm | Permalink

    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 My ComLuv Profile

  17. Posted April 24, 2010 at 9:24 pm | Permalink

    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 My ComLuv Profile

    • Posted May 6, 2010 at 6:33 am | Permalink

      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! My ComLuv Profile

      • Posted May 6, 2010 at 10:10 am | Permalink

        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.

  18. Posted April 28, 2010 at 12:42 am | Permalink

    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 My ComLuv Profile

    • Posted April 28, 2010 at 1:30 am | Permalink

      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?

      • Posted April 28, 2010 at 1:35 am | Permalink

        Hey Archon,

        Thanks for your quick response. I disabled the template cause it looked kinda bad. It should be enabled again now.

      • Posted April 28, 2010 at 7:25 am | Permalink

        Ok, I worked on it a little bit.
        I have this php

        Related Posts
        have_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 My ComLuv Profile

        • Posted April 28, 2010 at 5:05 pm | Permalink

          Try changing this on the style sheet
          .related-posts li
          to this
          .post ul li.related-posts

          Hope that works

  19. Posted April 29, 2010 at 11:32 pm | Permalink

    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 My ComLuv Profile

    • Posted April 30, 2010 at 6:58 am | Permalink

      Been using it for years but I entirely forgot about it because the plugin just works and I never had any issues.

  20. Posted May 11, 2010 at 3:07 am | Permalink

    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 My ComLuv Profile

    • Posted May 20, 2010 at 4:29 am | Permalink

      I can help you out if you could be more specific and share more details

      • Mark
        Posted May 20, 2010 at 4:59 am | Permalink

        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.

        • Mark
          Posted May 20, 2010 at 6:37 am | Permalink

          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.

        • Posted May 20, 2010 at 11:01 am | Permalink

          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.

  21. Alan
    Posted May 15, 2010 at 9:29 pm | Permalink

    Many many thanks, i was trying to do it myself but couldn’t work it out, you’re heaven sent!

  22. Posted May 21, 2010 at 8:39 am | Permalink

    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.

    • Posted May 21, 2010 at 8:47 am | Permalink

      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!

    • Posted May 21, 2010 at 9:06 am | Permalink

      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.jpg

      See 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=100

      Take note make sure the URL you put does not have anything else after .jpg as it will cause timthumb to display an error message.

      • Posted May 21, 2010 at 9:52 am | Permalink

        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?

        • Posted May 21, 2010 at 12:01 pm | Permalink

          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

  23. Posted May 21, 2010 at 12:45 pm | Permalink

    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 :)

    • Mark
      Posted May 22, 2010 at 2:41 am | Permalink

      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.

  24. Posted May 22, 2010 at 12:41 pm | Permalink

    This is great. We’ll be implementing this same related post template on our upcoming blog

  25. Posted June 14, 2010 at 4:40 pm | Permalink

    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 UsMy ComLuv Profile

  26. Posted June 21, 2010 at 1:10 pm | Permalink

    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

  27. Posted June 24, 2010 at 12:38 am | Permalink

    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,

  28. Posted June 28, 2010 at 2:20 am | Permalink

    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 1991My ComLuv Profile

  29. Posted July 11, 2010 at 2:33 pm | Permalink

    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.

  30. Posted July 11, 2010 at 6:00 pm | Permalink

    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

    • Posted July 11, 2010 at 7:20 pm | Permalink

      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.

      • Posted July 12, 2010 at 7:53 pm | Permalink

        Hi

        Thank you for the reply and the changes but, unfortunately, the code isn’t correct again. Your code shows the “>” as “&gt” and “<" as "&lt". 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

      • Posted July 12, 2010 at 7:56 pm | Permalink

        Hi

        Thank you for the reply and the changes but, unfortunately, the code isn’t correct again. Your code shows the “>” as “&gt” and “<" as "&lt". 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

        • Posted July 12, 2010 at 8:08 pm | Permalink

          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

        • Posted July 12, 2010 at 9:15 pm | Permalink

          Try it again, I just fixed the code again.

  31. Posted July 13, 2010 at 1:16 am | Permalink

    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

  32. Posted July 13, 2010 at 1:19 am | Permalink

    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

  33. Posted July 24, 2010 at 5:08 am | Permalink

    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 ReviewMy ComLuv Profile

  34. Steve Bruner
    Posted July 24, 2010 at 11:02 am | Permalink

    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.

    • Posted July 27, 2010 at 10:52 am | Permalink

      Hey thanks for the info, I’ll check out this plug-in you just posted

      • Posted July 29, 2010 at 7:55 am | Permalink

        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 picturesMy ComLuv Profile

        • Posted July 31, 2010 at 9:40 pm | Permalink

          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.

        • Posted August 1, 2010 at 2:45 am | Permalink

          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!My ComLuv Profile

        • Steve Bruner
          Posted August 1, 2010 at 5:12 am | Permalink

          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/

      • Posted August 10, 2010 at 6:14 am | Permalink

        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 BreezeMy ComLuv Profile

  35. Posted July 30, 2010 at 12:15 am | Permalink

    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

  36. Spyro
    Posted August 2, 2010 at 12:48 pm | Permalink

    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

  37. Robert from yarpp plugin
    Posted August 3, 2010 at 7:24 am | Permalink

    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/

  38. Tiger
    Posted August 5, 2010 at 7:46 am | Permalink

    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?

  39. Posted August 6, 2010 at 11:20 pm | Permalink

    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 AdvantagesMy ComLuv Profile

  40. Posted August 6, 2010 at 11:24 pm | Permalink

    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 AdvantagesMy ComLuv Profile

    • Spyro
      Posted August 9, 2010 at 10:40 am | Permalink

      @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

      • Wood Flooring
        Posted August 11, 2010 at 4:26 am | Permalink

        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.

        • Wood Flooring
          Posted August 11, 2010 at 4:30 am | Permalink

          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; ?]

  41. Posted August 11, 2010 at 2:49 am | Permalink

    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 BreezeMy ComLuv Profile

  42. Posted August 18, 2010 at 4:27 am | Permalink

    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 ToysMy ComLuv Profile

  43. Posted August 25, 2010 at 10:33 am | Permalink

    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-ThumbnailsMy ComLuv Profile

  44. aaron
    Posted August 30, 2010 at 8:59 am | Permalink

    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/

  45. Posted August 31, 2010 at 1:19 am | Permalink

    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 LaboralMy ComLuv Profile

22 Trackbacks

  1. By Kabayan Exchange on March 31, 2010 at 8:17 am

    RT @archondigital: LinkWithin – inspired YARPP Template http://bit.ly/cnuVer

  2. By bbrian017 on March 31, 2010 at 8:51 am

    RT @archondigital: LinkWithin-Inspired YARPP Template http://bit.ly/cnuVer vote for it over @blogengage #blogengage #networking #social

  3. By Pinapaitan on March 31, 2010 at 5:25 pm

    RT @archondigital: LinkWithin-Inspired YARPP Template http://bit.ly/cnuVer

  4. By Test post from Word 2010 | benway.net on April 1, 2010 at 10:38 pm

    [...] 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 [...]

  5. By Omer Greenwald on April 8, 2010 at 9:42 pm

    RT @archondigital: LinkWithin-Inspired YARPP Template http://bit.ly/cnuVer

  6. [...] 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. [...]

  7. By Valery Rybchenko on April 13, 2010 at 10:30 pm

    RT @archondigital: LinkWithin-Inspired YARPP Template http://bit.ly/cnuVer

  8. [...] thumbnails using timthumb. This is after a day of tinkering with LinkWithin. Read more of it here YARPP Template using Timthumb for Thumbnails [...]

  9. By Yet Another Related… on April 30, 2010 at 6:24 am

    A YARPP template which uses Timthumb for better post thumbnails! http://tinyurl.com/39pp76l

  10. By Theme Lab on April 30, 2010 at 6:30 am

    RT @yarpp: A YARPP template which uses Timthumb for better post thumbnails! http://tinyurl.com/39pp76l #wordpress

  11. By WizyWeb on May 1, 2010 at 12:42 am

    RT @yarpp: A YARPP template which uses Timthumb for better post thumbnails! http://tinyurl.com/39pp76l #wordpress /via @themelab

  12. By Jose Orestes on May 5, 2010 at 9:25 am
  13. [...] 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  [...]

  14. By Nexevi on May 10, 2010 at 7:01 am

    LinkWithin-Inspired YARPP Template http://su.pr/A6oo7G

  15. By Yaw Yan ArDigma on May 10, 2010 at 7:03 am

    LinkWithin-Inspired YARPP Template using Timthumb http://su.pr/A6oo7G

  16. By Pinapaitan on May 10, 2010 at 7:04 am

    Timthumb powered YARPP Template with thumbnails http://su.pr/A6oo7G

  17. By archondigital on July 11, 2010 at 11:29 am

    code snippet fixed! – LinkWithin-Inspired YARPP Template http://bit.ly/cnuVer

  18. [...] 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. [...]

  19. By Exciting LinkWithin for WordPress | QuickDaily on July 27, 2010 at 3:26 pm

    [...] YARPP也能提供类似功能(LinkWithin-Inspired YARPP Template),不过要稍显麻烦些,需要一个Timthumb的脚本,以便生成缩略图 LinkWithin的Related posts with thumbnails功能截图 [...]

  20. By James Fisher on July 29, 2010 at 10:00 pm

    RT @archondigital: LinkWithin-Inspired YARPP Template http://bit.ly/cnuVer

  21. By Get More Pageviews With LinkWithin on July 30, 2010 at 5:55 am

    [...] 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 [...]

  22. By Saad Bassi on September 1, 2010 at 4:37 pm

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv Enabled

This site uses KeywordLuv. Enter YourName@YourKeywords in the Name field to take advantage.

  • Search

  • Advertisement

  • Advertisment

  • Archives

  • Categories

  • CMF