Community Forums › Forums › Archived Forums › Design Tips and Tricks › Please help with old code – Featured Image
Tagged: featured image
- This topic has 5 replies, 2 voices, and was last updated 4 years, 9 months ago by
Victor Font.
-
AuthorPosts
-
August 10, 2018 at 1:16 am #222360
jbculp
ParticipantI 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 #222363Victor Font
ModeratorThere 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 #222370jbculp
ParticipantSorry 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 #222372jbculp
ParticipantVictor, Try this:
Pastebin LinkAugust 10, 2018 at 4:17 pm #222384jbculp
ParticipantGot 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 #222392Victor Font
ModeratorAwesome! 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? -
AuthorPosts
- The topic ‘Please help with old code – Featured Image’ is closed to new replies.