Wordpress Advanced Recent Posts Widget

Sean Scissors
Sean Scissors used Ask the Experts™
on
So I have created the following code and keep getting a syntax error but I am not sure where. I also don't think this code is quite right really. I have a gaming site and I am trying to create a widget that shows the most recent reviews with a small thumbnail image, publish date, number of comments and of course the title. I also want to be able to call my custom field reviewScore which is just a small image of the score. I got the idea from PSU.com Look at their sidebar on the right and that is basically what I am trying to accomplish but my coding skills aren't very worthy. Is the code below even close or am I so far off I should just look for plugins to do it?

Also my site is www.gamersciz.com
<?php 
$args = array( 'numberposts' => '2', 'category' =>'138');
	$recent_posts = wp_get_recent_posts( $args );
	foreach( $recent_posts as $post ){
		echo  '<ul> '.get_the_post_thumbnail($thumbnail->ID, array(70,81))'. <a href="' . get_permalink($post["ID"]) . '" title="Look '.$post["post_title"].'" >' .   $post["post_title"].'</a>.'comments_number( '0 comments', '1 comment', '% comments' )'. </ul> ';
	}
?>

Open in new window


**Note: I am using a plugin that allows me to code PHP directly into a text widget. It seems like it might be slowing the site down some but once I figure out the overall code I will just hardcode it into it's own widget maybe.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
<?php

Instead of  

echo  '<ul> '.get_the_post_thumbnail($thumbnail->ID, array(70,81))'. <a href="' . get_permalink($post["ID"]) . '" title="Look '.$post["post_title"].'" >' .   $post["post_title"].'</a>.'comments_number( '0 comments', '1 comment', '% comments' )'. </ul> ';

use

echo  '<ul> '.get_the_post_thumbnail($thumbnail->ID, array(70,81)).' <a href="' . get_permalink($post["ID"]) . '" title="Look '.$post["post_title"].'" >' .   $post["post_title"].'</a>'.comments_number( '0 comments', '1 comment', '% comments' ). '</ul> ';
Sean ScissorsProgram Analyst II

Author

Commented:
Thanks that fixed my error. Any chance you can figure out why within my loop the "get_the_post_thumbnail" is only getting the post thumbnail of the post you are currently on? I am trying to get it to show the thumbnail of the post within the foreach loop you know. Thanks though for a quick response.
Try changing $thumbnail->ID to $post['ID']
Sean ScissorsProgram Analyst II

Author

Commented:
Wow haha you know your PHP or Wordpress or perhaps both lol. Thanks that gives me a good start showing the comments, post title and thumbnail. Thanks again.
Sean ScissorsProgram Analyst II

Author

Commented:
Very quick and knowledgeable.
No problem.  Best of luck on your project, and thank you for the points!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial