Editing code to get a default post thumbnail image
-
Hi,
I currently feature five thumbnails at the top of my website, but each time I have to add a new image manually to each post so that the web design doesn’t break.
The current code in my index.php file is:
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args= array( 'posts_per_page' => 5, 'paged' => $paged ); query_posts($args); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php $thumbnail = get_post_meta($post->ID, 'post_thumbnail', true); ?> <li> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> <img src="<?php echo $thumbnail; ?>" alt="<?php the_title(); ?>" /> <span><?php the_title(); ?></span></a> </li> <?php endwhile; else: ?><p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?></ul>I’ve downloaded various plugins and read lots of blog posts but don’t know exactly how to go about editing the ‘else’ part of the code to determine the URL of a generic thumbnail image.
Any tips? I am not that used to PHP code so any advice would be grealy appreciated! My main for doing this is that I will then be able to instantly add posts from my iPhone without needing to go online to determine the post_thumbnail custom field.
For reference, my website is http://www.jeniwren.com
The topic ‘Editing code to get a default post thumbnail image’ is closed to new replies.