How can I can I check if a post has a thumbnail and if does do something? If doesn’t do something else. This is what I have:
<?php if(have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php if ( has_post_thumbnail() ) { ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php
}else{
?>
<?php the_post_thumbnail(); ?>
<?php
}
?>
<?php endwhile; ?>
<?php endif; ?>
Any help will be appreciate it.
You already have this, in the line
you are checking if the post has thumbnail, the problems is that you put wrong code in else statement, you have to put something like:
Try with these line of codes:
To link Post Thumbnails to the Post Permalink in a specific loop, use the following within your Themeâs template files:
firstly CHECK your functions.php file for this
if its not in there, copy and paste that into your file..
Secondly Add this to your functions.php
this lets you return the Image src, and not just print the entire img tag
Then on your template page change your code to something like:
this was used as a background image
this should produce a div with a background image applied to it,
If you want the Full img tag code to be printed simply use one of the following.
Marty..