Show Image Thumbails with Blog Excerpts or Posts on Static Homepage using the WordPress Thesis Theme
on July 30, 2012

WordPress plus Thesis gives you the flexibility to easily customize your site with features such as displaying posts and thumbnails on your homepage.
function static_front_posts(){ if (is_front_page()) { ?> <div id="my-static-front-posts"> <?php $custom_loop = new WP_Query('showposts=10&amp;amp;amp;orderby=date'); if ( $custom_loop->have_posts() ) : while ( $custom_loop->have_posts() ) : $custom_loop->the_post(); echo '<div class="post type-post hentry post_box top">'; $post_image = thesis_post_image_info('thumb'); echo $post_image['output']; echo '<div class="headline_area"><h2 class="entry-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>'; echo '<p class="headline_meta"><abbr title="" class="published">' . get_the_date() . '</abbr></p></div>'; echo '<div class="format_text entry-content"><p>' . get_the_excerpt() . '</p></div>'; echo '<a href="' . get_permalink() . '">' . '<span class="more-button">Read More</span></a>'; echo '</div>'; endwhile; wp_reset_query(); endif; ?></div><?php } } add_action('thesis_hook_after_content','static_front_posts');
Refresh your homepage and voila, image thumbnails should show along with the excerpts.
PLEASE NOTE: For image thumbnails to show, ensure that you have added an image to your post. Also, for the above code to work properly, you need set your front page to a static page and set up a blog page for your posts. For more info, please see our original post about adding posts to a static front page.
Hi,
This looks like what I need. However I want to add posts from cat=7 to another page (121) on my site. After looking at your code, I see I could maybe change
if (is_front_page())
to
if (is_page(‘121’))
But where can I specify that I just want posts from cat=7? I see something here:
6.$custom_loop = new WP_Query(‘showposts=10&amp;amp;orderby=date’);
But I’m not sure how to modify it. Can you help me? Thanks ,,,-Licia
[…] Show Image Thumbails with Blog Excerpts or Posts on Static Homepage using the WordPress Thesis Theme Tweet […]
Hi Licia,
Something along these lines should work for you (replace the cat=4 with the category you want to display): $custom_loop = new WP_Query( ‘cat=4’ );
You can checkout the parameters for the WP_Query class here: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters.
Hi! I’m wondering if there’s some code to add that would make the images clickable through to the appropriate blog post page. That would be awesome!
Hi Kaitlin, you can make the images clickable using the same
code that is used for the post title itself.
Really thank you for these articles!
I used the code you explained to add posts on a static homepage and it works, but unfortunatly I can’t add the thumbnails.
I tried your code and I tried billions of other changes but when I put your code in the functions.php and in the frontpage template (where the posts should me visible) It gives me a fatal error
exactly a this row
$post_image = thesis_post_image_info(‘thumb’);
echo $post_image[‘output’];
Please help me I’m becoming crazy.
Thanks
Sure, can you send us a copy of your functions.pho file? Contact @ collaboration133.com. Also, what theme are you using?
I can’t get this to work. please help my theme does not av custom_functions.php file it only has functions.php file……. help me ooo
If you are using a different theme, you’ll need to update the code. It will go in functions.php if your theme has that file. Let us know if you need further help.
Hi,
your comments aren’t showing! I had this problem, there is an easy fix. It’s to do with the latest wp version and thesis.
But … I can’t get this code to work. I’m told there is an error, but I can’t see it. I was rather hoping the people who have commented on this could have been talking about it.
Thanks for the code by the way. I will persevere.
kind regards.
I couldn’t get this to work. I couldn’t open my site and had to delete using ftp.
I haven’t been able to see the problem
Also, I can’t see the comments on this page. I’m hoping there might be an answer there.