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
https://forums.phpfreaks.com/topic/247272-wordpress-related-posts/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.