WordPress.org

Ready to get started?Download WordPress

Forums

Random posts with timthumb? (1 post)

  1. manga
    Member
    Posted 5 years ago #

    Hello!!

    My homepage is http://otoboku.se and I´m using the Arthemia theme which I´ve modified by a lot. I wanted to try how it would look if I tried to have a random posts section as seen here:
    http://demo.colorlabsproject.com/arthemia/

    The thing is that I want to use the timthumb resizer to make the same effect. While I can make it so that I get random posts the pain is that the same thumbnail is used for every single post.

    When that happends I follow the example

    <ul><li><h2>A random selection of my writing</h2>
        <ul>
     <?php
     $rand_posts = get_posts('numberposts=5&amp;orderby=rand');
     foreach( $rand_posts as $post ) :
     ?>
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
     <?php endforeach; ?>
        </ul>
     </li></ul>

    But I make a bit of a change.

    <h3>Random posts</h3>
    
     <?php
     $rand_posts = get_posts('numberposts=7&amp;orderby=rand');
     foreach( $rand_posts as $post ) :
     ?>
    
    <?php	$values = get_post_custom_values("Image");
    	if (isset($values[0])) { ?>
          <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    	<img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
    $values = get_post_custom_values("Image"); echo $values[0]; ?>&amp;w=120&amp;h=120&amp;zc=1&amp;q=100"
    alt="<?php the_title(); ?>" class="left" width="285px" height="150px"  /></a>
          <?php } ?>
    
    <?php endwhile;?>

    This displays a list of random posts. But with the same image.

    Any easy way to fix this so that everything works out nicely? I´m at a loss of what to do next.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.