Jump to content

Wordpress - Related Posts


wblake37

Recommended Posts

Im still new to php and was looking for some help with this code, it displays random posts with images, what i want is related posts by "tags" or "categories"

 

Its for wordpress.

 

original code:

<?php $recent = new WP_Query("cat=<? echo $tg_video_post; ?>&showposts=5&orderby=rand"); while($recent->have_posts()) : $recent->the_post();?>
		<div class="singleright">
			<div class="singlerightimage">
				<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><img src="<?php $values = get_post_custom_values("thumb"); echo $values[0]; ?>" width="90" height="54" alt="<?php the_title_attribute(); ?>" /></a>
			</div>
			<div class="singlerighti">
				<div class="singlerightinfo">
					<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php $tit = the_title('','',FALSE); echo substr($tit, 0, 50); if (strlen($tit) > 50) echo " ..."; ?></a>
				</div>
				<div class="postviews">
					<?php the_time('F jS, Y') ?>  
				</div>
				<div class="postviews">
					<?php if(function_exists('the_views')) { the_views(); } ?>  
				</div>
			</div>
		</div>
	<?php endwhile; ?>

 

Any help is greatly appreciated

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.