• 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

Conditionally Removing 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 › Conditionally Removing Featured Image

This topic is: not resolved

Tagged: featured image conditional tags

  • This topic has 1 reply, 2 voices, and was last updated 9 years, 4 months ago by Victor Font.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • December 14, 2016 at 1:39 pm #197580
    jackirt
    Member

    Hello!

    I've followed this tutorial to add a Second Featured Image to my posts. It works great, however I was wondering if there is a code I could write that would conditionally remove the ORIGINAL featured image, IF a second featured image has been added. (We are wanting to have the original featured image displayed in a post slider, while removing the original featured image and displaying the second featured image on the blog page)

    I've tried writing my own conditional statement, but can't seem to get it to work. Any thoughts would be appreciated!

    Below is what has been added to my functions.php file apart from the ACF creation:

    //* Dual Featured Image
    add_action( 'genesis_before_entry', 'custom_field_before_content' );
    
    function custom_field_before_content() {
      if (is_page() && is_singular('post')) return;
       if( get_field('second_image') ):
    	?><div class="second-img"><img src="<?php the_field('second_image'); ?>" alt="" /></div><?php
    endif;
      
    }
    December 16, 2016 at 2:07 pm #197701
    Victor Font
    Moderator

    You can probably integrate the following. This tests for the existence of both (based on your code above), and removes the first.

    if ( genesis_get_option( 'content_archive_thumbnail' ) && get_field('second_image') ) {
        remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
    }

    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

  • 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

© 2026 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