This is the code:
- Code: Select all
<div id="random">
<h3><?php _e('Random Posts','arthemia');?></h3>
<?php $width = get_settings ( "cp_thumbWidth_Gallery" );
$height = get_settings ( "cp_thumbHeight_Gallery" );
if ( $width == 0 ) { $width = 80; }
if ( $height == 0 ) { $height = 80; }
$status = get_settings ( "cp_thumbAuto" );
?>
<?php $randompost = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY RAND() LIMIT 9");
foreach ($randompost as $post) {
$ID = $post->ID;
$postid = get_post($post->ID);
$title = $postid->post_title;
$values = $wpdb->get_var("SELECT meta_value FROM $wpdb->postmeta WHERE post_id = $ID AND meta_key = 'Image' ");
?>
<?php if ( $status != "first" ) { ?>
<?php
if (isset($values)) {
?>
<a href="<?php echo get_permalink($postid); ?>" rel="bookmark" title="<?php echo $title; ?>"><img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
echo $values; ?>&w=<?php echo $width; ?>&h=<?php echo $height; ?>&zc=1&q=100"
alt="<?php echo $title; ?>" class="left" width="<?php echo $width; ?>px" height="<?php echo $height; ?>px" /></a>
<?php } ?>
<?php } else { ?>
<?php $id =$post->ID;
$the_content =$wpdb->get_var("SELECT post_content FROM $wpdb->posts WHERE ID = $id");
$home = get_option('home');
$pattern = '!<img.*?src="'.$home.'(.*?)"!';
preg_match_all($pattern, $the_content, $matches);
$image_src = $matches['1'][0]; ?>
<?php if($image_src != '') { ?><a href="<?php echo get_permalink($postid); ?>" rel="bookmark" title="<?php echo $title; ?>">
<img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=<?php echo $image_src; ?>&w=<?php echo $width; ?>&h=<?php echo $height; ?>&zc=1&q=100"
alt="<?php echo $title; ?>" class="left" width="<?php echo $width; ?>px" height="<?php echo $height; ?>px" /></a><?php } ?>
<?php } ?>
<?php } ?>
<div class="more" style="margin-top:-10px;padding-right:15px;font-weight:bold;float:right;"><a href="javascript:location.reload()" target="_self"><?php _e('(refresh random posts)','arthemia');?></a></div>
</div>
Hope you can help me.. I tried to edit it on CSS but it always show on a 6 by 2..
Another question there is a limit on mysql query.. Is there a minimum? For example it will always show minimum images?
Sorry for my english.. Please help me.. Thanks!

