• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Add Post Thumbnail to custom container widget

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Add Post Thumbnail to custom container widget

This topic is: resolved

Tagged: custom sidebar, functions, post thumbnail

  • This topic has 1 reply, 2 voices, and was last updated 12 years, 4 months ago by Brad Dalton.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • August 4, 2013 at 6:49 am #54084
    musicmeg
    Member

    I created a custom widget container above my content. (Picture here: http://i1282.photobucket.com/albums/a537/singinglawlady/ScreenCaptureatSunAug4074157CDT2013.png~original)

    What I want to do is add the post thumbnail in each of the categories. So when a new post in that category is posted, the thumbnail automatically updates.
    Here is the code in my functions file:

    genesis_register_sidebar( array(
            'id'            => 'x_widget',
            'name'          => __( 'Homepage Below Menu' ),
            'description'   => __( 'This is below the bottom menu of the homepage.' ),
    ) );
    
    	add_action( 'genesis_before_content', 'widget_before_content' );
    	function widget_before_content() {
     	   echo '<div id="x_widget">';
    		echo '<a href="/blogtest/category/review/" class="feat_img"><div class="promo_sect"><div class="promo_sect_img" style="background-image: url(<?php echo $thumb_src[0];?> ) !important;"></div>BOOK REVIEWS</div></a>';
    		echo '<a href="/blogtest/category/cover-reveal/" class="feat_img"><div class="promo_sect"><div class="promo_sect_img" style="background-image: url( get_post_thumbnail_id($post->ID);"></div>COVER REVEALS</div></a>';
    		echo '<a href="/blogtest/category/GIVEAWAYS/" class="feat_img"><div class="promo_sect"><div class="promo_sect_img" style="background-image: url( get_post_thumbnail_id($post->ID);"></div>GIVEAWAYS</div></a>';
    		echo '<a href="/blogtest/category/Book-News/" class="feat_img"><div class="promo_sect"><div class="promo_sect_img" style="background-image: url( get_post_thumbnail_id($post->ID);"></div>BOOK NEWS</div></a>';
    		echo '<a href="/blogtest/category/cover-reveal/" class="feat_img"><div class="promo_sect"><div class="promo_sect_img" style="background-image: url( get_post_thumbnail_id($post->ID);"></div>COVER REVEALS</div></a>';
        	echo '</div>';
    }
    

    Is there an easier or different way to do this? I have the CSS styling done, but I can't figure out how to make the post thumbnail show up without manually putting the image url inside the background-image: url ( field. I am clearly not a pro, so any and all help is appreciated.

    http://readingbookslikeaboss.com
    August 5, 2013 at 10:58 pm #54336
    Brad Dalton
    Participant

    Another option would be to create multiple widget areas side by side and drag in the Genesis featured posts widgets with the settings to display 1 post so only the latest post thumbnail displays.

    You could use existing code from another child theme which includes widgets side by side and add more widgets to the PHP code as well as modify the CSS.

    I did see what you have done and thinks its a great idea however there are different ways to code the same solution.

    How may thumbnails did you want to display in a horizontal row?


    Tutorials for StudioPress Themes.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble