danaldinho
Member
Posted 2 years ago #
Does anyone know the code to make an image show on the single post and pages only?
This code below works:
<?php if (is_page()) : ?>
IMAGE GOES HERE
<?php endif; ?>
<?php if (is_single()) : ?>
IMAGE GOES HERE
<?php endif; ?>
But I was looking at only posting the image once in one piece of code. I have tried this:
<?php if (is_single() && is_page()) : ?>
IMAGE GOES HERE
<?php endif; ?>
But no luck :(
Hope someone can help me out.
Thanks, appreciate it.
Your current code translates to "If this is a single post AND a static page..." which, obviously is never going to be true. Try:
<?php if (is_single() || is_page()) : ?>
IMAGE GOES HERE
<?php endif; ?>
which replaces your AND with an OR.
Lynne and Chad
Member
Posted 2 years ago #
Is it the same image you want to use all the time? Or different for each post?
If it's just one image to be used on all posts, you should be able to add the image tag to the single.php file in your theme and be all set :)
danaldinho
Member
Posted 2 years ago #
Thanks esmi, appreciate it.