WordPress.org

Ready to get started?Download WordPress

Forums

Custom related posts with thumbnails (3 posts)

  1. Czymra
    Member
    Posted 5 years ago #

    Hey everybody.

    I have a blog that hosts only videos and I want to relate them to each other via tags.
    So there is this section that pulls thumbnails from attached images of another post in order to offer up other clips which looks like this:

    <?php $my_query = new WP_Query('tag__in=tag3&amp;orderby=rand&amp;cat=6&amp;showposts=3'); ?>
    
      <?php while ($my_query->have_posts()) : $my_query->the_post(); if( $post->ID == $current ) continue; ?>
    
    <a href="<?php the_permalink(); ?>"><?php $images =&amp; get_children( 'post_type=attachment&amp;post_mime_type=image&amp;post_parent=' . $post->ID );
    $firstImageSrc = wp_get_attachment_image_src(array_shift(array_keys($images)));
    echo "<img src=\"{$firstImageSrc[0]}\" width=\"50\" height=\"50\" />"; ?></a>
    &nbsp;
    	<?php endwhile;?>

    Now at the moment the tag is 'tag3' which was a test tag and doesn't actually exist anymore. The function runs nevertheless but the pattern is neither random nor can I deduce any logic from it.

    What I would love to do is to put all the posttags in an array and pass that on to the 'tag__in', but I'm not sure if that can even read multiple tags, and my PHP basics are pretty bad so I've been playing with it rather unsuccessfully even after googling my way around on how to pass arrays or checking out the parameter s in the codex.

    Any help would be greatly appreciated.
    Thanks,
    Czymra

  2. Czymra - this is possible with the templating feature in version 3 of the Yet Another Related Posts Plugin... the explanation is here:

    http://mitcho.com/blog/projects/yarpp-3-templates/

  3. Czymra
    Member
    Posted 5 years ago #

    Thanks a lot. I'll check it out as soon as I get some time.

    ありがとおございました。I guess... ;)

Topic Closed

This topic has been closed to new replies.

About this Topic