• 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

How to define a default featured image

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 › How to define a default featured image

This topic is: not resolved

Tagged: featured image

  • This topic has 6 replies, 4 voices, and was last updated 10 years, 4 months ago by Genesis Developer.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • March 7, 2015 at 8:25 pm #143621
    swc
    Member

    I'm working on a custom version of the Ambient Pro theme that uses featured images in a grid for the default blog page. It's great except that it's going on a site that has been around a while and some of the old posts don't have featured images. Since the titles are white and normally sit over a featured image, they disappear without a featured image. What I'd like to do is simply define a default featured image for posts that do not have one. This should be simple enough, but I'm not sure what filter to hook into to define an image if the standard function did not return one.

    March 7, 2015 at 9:10 pm #143627
    Brad Dalton
    Participant

    I would use a plugin like what Travis Smith has coded Genesis featured image https://wordpress.org/plugins/genesis-featured-images/

    Or this one by Robin Cornett https://wordpress.org/plugins/display-featured-image-genesis/


    Tutorials for StudioPress Themes.

    March 7, 2015 at 9:35 pm #143628
    Abland
    Member

    Hi, swc,

    This works for me in the theme functions.php

    //--> DEFAULT FEATURED IMAGE
    add_filter( 'genesis_pre_get_image', 'default_featured_image_when_not_set', 10, 1 );
    function default_featured_image_when_not_set( $post ) {
    if ( '' != get_the_post_thumbnail() ) :
        return $post;
    else: 
       echo '<img src="//path/to/image.png" width="150" class="alignleft" />';
    endif;
    }
    March 7, 2015 at 9:46 pm #143629
    Brad Dalton
    Participant

    @Abland, not a bad solution but what happens with image alignment and size when you change the Genesis > Theme Settings > Content Archives > Featured image settings?

    How do they match your default?


    Tutorials for StudioPress Themes.

    March 7, 2015 at 10:08 pm #143631
    Abland
    Member

    Hi, braddalton,

    Good point to notice - this was from one site.

    To anyone reading: where the image src is echoed adjust width and class to what's needed.

    March 8, 2015 at 9:29 am #143672
    swc
    Member

    Thanks - that code snippet was really helpful and solved the problem.

    March 8, 2015 at 9:46 am #143675
    Genesis Developer
    Member

    If you try following snippets then what is happening?

    add_filter( 'genesis_pre_get_image', 'default_featured_image_when_not_set', 10, 2 );
    function default_featured_image_when_not_set( $post , $args ) {
    if ( '' != get_the_post_thumbnail() ) :
        return $post;
    else: 
       echo '<img src="//path/to/image.png" width="150" class="' . $args['attr']['class'] .'" />';
    endif;
    }

    Download Genesis Featured Posts Combo Widget | Simple Grid Layouts Plugin for Posts, CPTs and terms
    You can request new tips/help.

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 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