If you’re using the Arthemia Premium WordPress theme, then you may have come across this problem: The “Random Posts / Video” footer you can choose to have at the bottom of some of your pages assumes that ALL of your posts have thumbnails available. The problem I have is that a lot of my older posts don’t, so I dont get twelve neat little thumbnails – in most cases I get less than twelve.

There are a number of ways to fix this. The problem is simply that the code as it’s written only selects twelve posts at random, regardless of whether they have thumbnails or not. The simplest fix is to modify the code to retrieve more than twelve posts, then discard the ones that don’t have thumbnails. It’s a bit of a botch solution though. A better approach would be to modify the initial SQL query to only retrieve posts that have thumnails – but that’s a little more complicated than it first appears. Also, you could modify the code below to not discard posts, but detect when no thumbnail is available, and offer a generic thumnail instead. Whatever floats your boat – I found the first solution works just fine for me ;o)

Note that this modification only works if you’re using the custom “Image” field to manage your thumbnails in Arthemia. If you’re using the “First Image” option, then this code won’t fix the problem.

Locate your “footer.php” file within your “arthemia-premium” theme, and change the code as follows at around line 24:


get_results("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY RAND() LIMIT 6"); 

	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' ");

etc ...


get_results("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY RAND() LIMIT 24");

	$iCount = 0;
	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' ");

		if ($values != "") { $iCount += 1; }

		if ($iCount == 13) { break; }

etc ....

Make sure you change the SQL query to retrieve more than 12 posts. I’ve set it to 24 (“LIMIT 24”), which works for me. If you have a higher percentage of posts without thumbnails, you may wish to increase this – or consider the other options I mentioned above.

So there you go :o)


Vivek · 13 October 2009 at 9:28 pm

Hey, this is nice option! Though I use the ‘First Image’ option and so it is not applicable for me, I wanted to seek help regarding the ‘Video’ towards the left of the random posts. It just doesnt work for me. Any pointer would be appreciated.

MIke · 8 November 2009 at 11:27 am

Small bugs in your code… remove all the “;” after “->” and it will works for me..

    Oli · 9 November 2009 at 11:39 pm

    Ah yes, well spotted. They’re left over from an update where WordPress tried to “help” me by inserting all sorts of nonesense! I’ll correct them when I get a chance. Thanks!

Waqas Nasir · 1 May 2010 at 9:33 pm


My site is http://www.cric20.com
Using Arthemia Premium
Can anyone tell me why the random posts on my site , are going to 3 rows and not showing 6 on a row but only 5 ..
strange ..
i didnt change the code i guess .. either the source is originally corrupted or may be a small css error etc might be causing it … its beyond my understanding ..
Some of my posts were without pictures, but i have placed pictures on all now ..

If you need code to review , i can provide you that ..

Oli · 2 May 2010 at 11:09 am

Hi Waqas – Your random posts section looks fine from here: 2 rows of 6 viewed using both Safari and Firefox. What browser are you using?

Waqas Nasir · 2 May 2010 at 9:34 pm

Actually the situation is beyond my understanding …
On my laptop i have both chrome and firefox and it looks perfect on it with 1024X600 resolution.

When i move to desktop having 1280X1024 it shows that problem.
And i have checked it on other computer too with 1280X1024 resolutions and the result was same.

But on the other hand, when i see the Arthemia demo on their website, the demo looks perfect on this 1280X1024 resolution ..

So problem is somewhere in my theme, and might be some CSS issue ..what ever .. but i fail to understand it ..

shai · 24 May 2010 at 12:45 pm


I had some probelms with the footer plugins, and after some modifications, it doesn’t show any plugin positioned on the bottom at all, except on the right side.

How can i fix it?

Thanks a lot in advance!!

Prashant · 30 December 2010 at 10:27 am

Hello, I don’t know why random posts are nt being dispayed…
My Site URL: techlazy.com

Plz Help

Tatiana · 1 February 2011 at 7:27 am

Thank you so much! It was really usefull and I didn;t have idea were to look for these random image settings 🙂

Leave a Reply

Avatar placeholder

Your email address will not be published.