Community Forums › Forums › Archived Forums › Design Tips and Tricks › Add Featured Image only to new blog post
Tagged: conditional tags, featured image, single post
- This topic has 5 replies, 2 voices, and was last updated 8 years, 9 months ago by sevenbillionbuddhas.
-
AuthorPosts
-
July 8, 2015 at 2:36 am #158761sevenbillionbuddhasMember
My brain isn't doing the logic on this one very well at all. It's a simple solution I'm sure!
I've imported 300 posts from an old blogspot blog into a new Genesis build. The first image in all the blogspot posts was attributed to the Featured Image - great! However, the image is also in the content so the image is showing twice. I was thinking to separate imported posts from new posts using categories, then use a conditional tag to filter out the old blogspot posts to not show the featured image. Is this the best way to go about it? If so, what's the recommended way to change the code below?
My brain cannot do the logic right now!This is the code I've used to add the featured images to posts:
/* Code to Display Featured Image on top of the post */
add_action( 'genesis_entry_content', 'featured_post_image', 8 );
function featured_post_image() {
if ( ! is_singular( 'post' ) ) return;
the_post_thumbnail('post-image');
}Thank yoU!
http://edtrost.ipower.com/everything-changes/July 8, 2015 at 4:24 pm #158841Brad DaltonParticipantBest way is to use the Featured Image meta box located on all Edit post screens.
You can then remove the duplicate image using PHP code which prevents Genesis using the first attachment image as the featured image.
July 9, 2015 at 2:56 am #158885sevenbillionbuddhasMemberHey thanks Brad, that didn't do the trick. I don't think I explained well. Let me try again.
Basically, I need a way to display featured images above all single posts EXCEPT for the old imported posts (where Genesis is pulling the first image as featured image).
Any ideas?
July 10, 2015 at 7:14 pm #159062Brad DaltonParticipantUnderstand. The post i linked to also includes a link to a related post which includes the code to display your featured image before or after the post title on single posts/
However, you may need to add a conditional check for when Genesis is pulling the first image as featured image.
July 10, 2015 at 7:17 pm #159063Brad DaltonParticipantUnderstand. The post i linked to also includes a link to a related post which includes the code to display your featured image before or after the post title on single posts/
However, you may need to add a conditional check for when Genesis is pulling the first image as featured image.
Please note: Some tutorials are free to access and some are for members only.
July 10, 2015 at 9:16 pm #159067sevenbillionbuddhasMemberI solved it! My solution here in case others have the same question.
First, I removed the featured images from the old posts in bulk using this technique.
http://www.wpbeginner.com/wp-tutorials/how-to-bulk-remove-featured-images-from-posts-in-wordpress/I then added the featured image below the post title with this code:
/* Code to Display Featured Image on top of the post */
add_action( 'genesis_before_entry_content', 'featured_post_image', 8 );
function featured_post_image() {
if ( ! is_single( 'post' )) return;
the_post_thumbnail('post-image');
}It worked great. Now on new blog posts, the client can add a featured image and it will show below the post title. All old blog posts only are showing the image in the content, no more double images from featured image + content image! WordPress pulls in the first image from the old content as the featured image on archive pages, so it all works brilliantly now.
Thanks for responding.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.