• 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

Please help with old code – 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 › Please help with old code – Featured Image

This topic is: resolved

Tagged: featured image

  • This topic has 5 replies, 2 voices, and was last updated 4 years, 9 months ago by Victor Font.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • August 10, 2018 at 1:16 am #222360
    jbculp
    Participant

    I have inherited an old Genesis site and need to keep it going until a mobile responsive version can be made. That said I am not a PHP Coder. Can someone help me with this code block? I'll give the code then the two DEBUG messages. It's possible that this is old code that is no longer supported or has changed. I've fixed a couple of things that fit that description. If I'm reading the debug message correctly the error is near the top. The code provided begins on line 111.

    // get the featured image URL
    // http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src
    
    if (has_post_thumbnail() ) {
    	$featured_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'column-fill' );
    }
    ?>
    <div <?php post_class('columns'); ?> 
    	<?php echo (has_post_thumbnail()) ? 'style="background-image: url(' . $featured_image[0] . ');"' : ''; ?>>
    
    	<div class="column-blurb">
    
    		<?php do_action( 'genesis_before_post_title' ); ?>
    		<?php do_action( 'genesis_post_title' ); ?>
    		<?php do_action( 'genesis_after_post_title' ); ?>
    
    		<div class="entry-content">
    			<?php echo apply_filters('the_content', $blurb_content); ?>
    			<?php apply_filters( 'genesis_edit_post_link', true ) ? edit_post_link( __( '(Edit)', 'genesis' ), '', '' ) : ''; ?>
    		</div><!-- end .entry-content -->
    	</div> <!-- end .column-blurb -->
    
    	<div class="column-featured">
    		<?php do_action( 'genesis_before_post_content' ); ?>
    			<div class="entry-content">
    				<?php echo apply_filters('the_content', $featured_content); ?>
    			</div><!-- end .entry-content -->
    			
    			<?php do_action( 'genesis_after_post_content' ); ?>
    				
    	</div> <!-- end .column-feature -->
    			
    </div> <!-- end .postclass.columns -->

    Error messages from Debug:
    [10-Aug-2018 06:08:41 UTC] PHP Notice: Undefined variable: post in /home/content/51/9025851/html/wp/wp-content/themes/{custom theme name}/functions-loops.php on line 116

    [10-Aug-2018 06:08:41 UTC] PHP Notice: Trying to get property of non-object in /home/content/51/9025851/html/wp/wp-content/themes/{custom theme name}/functions-loops.php on line 116

    Thank you anyone who is PHP savvy.

    http://dmeyersjeweler.com/
    August 10, 2018 at 4:26 am #222363
    Victor Font
    Moderator

    There aren't 116 lines in the code you posted. Post the entire content of functions-loops.php on Pastebin (not here), then post the link to the pastebin here.


    Regards,

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

    August 10, 2018 at 7:32 am #222370
    jbculp
    Participant

    Sorry Victor, I started at 111. I've not posted on this forum since Pastebin became a thing. Will figure that out and then post the link here.

    August 10, 2018 at 9:14 am #222372
    jbculp
    Participant

    Victor, Try this:
    Pastebin Link

    August 10, 2018 at 4:17 pm #222384
    jbculp
    Participant

    Got it.
    Replaced this:
    $featured_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'column-fill' );

    with this:
    $featured_image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'column-fill');

    August 11, 2018 at 9:36 am #222392
    Victor Font
    Moderator

    Awesome! Glad you figured it out.


    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 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Please help with old code – Featured Image’ is closed to new replies.

CTA

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

Create a site with WP EngineShop for Themes

Footer

StudioPress

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