Community Forums › Forums › Archived Forums › Design Tips and Tricks › Add featured image to top of blog page
Tagged: blog page featured image
- This topic has 6 replies, 4 voices, and was last updated 12 years, 1 month ago by
Celeste.
-
AuthorPosts
-
May 13, 2014 at 10:38 am #104924
Celeste
MemberHello. I am working with the Sixteen Nine theme and am using featured images to act as section headers on posts and pages. I would also like to use a featured image at the top of my blog page, but it is not showing up there. The blog is not my home page, but a separate page using the blog template.
Here is a link to the page: http://temp.inwelligenthc.com/blog/. If you click one of the post titles you will see a featured image at the top of the single post. This is what I am trying to add the top of the blog page.
The function I am currently using is for single_post_featured_image. I assume I need to add something extra to get the image to show up on the blog page.
Any insight would be appreciated!
http://temp.inwelligenthc.com/blog/May 13, 2014 at 4:34 pm #104979nerdworker
MemberHello,
I'm not clear on whether you want to show all the posts' featured images on the archive page or if you are just trying to show one specific image at the top of the page. If you just want to show featured images on the archive page, there is a setting in the Genesis Theme Settings, under Content Archives to include featured images.
If you want to show one specific image at the top of the archive page, then you may need to add a hook to the page in the correct area. This visual guide might help establish where to put it: http://genesistutorials.com/visual-hook-guide/
Sorry that I'm not exactly sure how to answer.
Regards,
Stefanie
nerdworker.comMay 14, 2014 at 5:46 am #105061Celeste
MemberHi Stefanie, thanks for your response. I am trying to do the latter: add one specific image to the top of the blog page. I am currently using the following function to display the featured image at the top of posts and pages, but it is not showing up on the blog page:
//* Add featured image to posts and pages
add_action( 'genesis_entry_header', 'single_post_featured_image', 5 );
function single_post_featured_image() {
if ( ! is_singular() )
return;$img = genesis_get_image( array( 'format' => 'html', 'size' => genesis_get_option( 'image_size' ), 'attr' => array( 'class' => 'post-image' ) ) );
printf( '%s', get_permalink(), the_title_attribute( 'echo=0' ), $img );}
I assume 'single_post_featured_image' does not apply to the blog page (my assumption could be wrong). I have searched forums and internet for the exact function I need but haven't found anything.
Thanks,
CelesteMay 14, 2014 at 7:36 am #105086Lauren @ OnceCoupled
MemberIt's not being inserted because your conditional (
is_singular()) is stopping it. If your blog page is a template, why not take that code and insert it into your template? You wouldn't need the conditional logic any more, so it would just look like:add_action( 'genesis_entry_header', 'single_post_featured_image', 5 ); function single_post_featured_image() { $img = genesis_get_image( array( 'format’ => 'html', 'size' => genesis_get_option( 'image_size' ), 'attr' => array( 'class' => 'post-image' ) ) ); printf( '%s', get_permalink(), the_title_attribute( 'echo=0′ ), $img ); }By the way, use the code tags, or insert a github gist, when you're putting code in the forms.
Best,
Lauren
We create mobile-first, PageSpeed-optimized, pixel-perfect custom themes! https://www.oncecoupled.com
May 15, 2014 at 6:22 am #105272Celeste
MemberHi Lauren, I apologize for my ineptitude, but can you direct me on how to add your code to the blog template (it is not a template I made, it is the standard Genesis blog template)? I copied page_blog.php into my child theme folder, but I am unclear on how to modify Genesis page templates. It is very different than the standard WordPress page templates I've worked with before. I am only assuming page_blog.php is the right file to edit?
Thanks again,
CelesteMay 15, 2014 at 6:55 am #105278Brad Dalton
ParticipantYou can hook it in using the
is_page_template('page_blog.php'))conditional tag.
The last 2 code snippets should help http://wpsites.net/web-design/add-content-before-posts-blog-page-only/
May 15, 2014 at 9:36 am #105320Celeste
MemberThanks so much Brad! The last snippet on your page worked.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.