Title: PHP error / eval()&#8217;d code
Last modified: March 26, 2023

---

# PHP error / eval()’d code

 *  Resolved [HighKay](https://wordpress.org/support/users/hlorenz/)
 * (@hlorenz)
 * [3 years ago](https://wordpress.org/support/topic/php-error-583/)
 * Hi,
 * since I changed to PHP 8.0 I get this error-Message:
 * plugins/code-snippets/php/snippet-ops.php(504) : eval()’d code on line 11
 * How can I find out, which snippet is causing this error?
 * Thanks for your help
   Heike
    -  This topic was modified 3 years ago by [HighKay](https://wordpress.org/support/users/hlorenz/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fphp-error-583%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [3 years ago](https://wordpress.org/support/topic/php-error-583/#post-16595774)
 * Hi Heike,
 * Do you have the full error message available? All I can tell you from that is
   that the error occurred on line 11 of a snippet.
 *  Thread Starter [HighKay](https://wordpress.org/support/users/hlorenz/)
 * (@hlorenz)
 * [3 years ago](https://wordpress.org/support/topic/php-error-583/#post-16595842)
 * Hi [@bungeshea](https://wordpress.org/support/users/bungeshea/) ,
 * here is the complete error message:
 *     ```wp-block-code
       Undefined variable $post in xxxxx/wordpress/wp-content/plugins/code-snippets/php/snippet-ops.php(504) : eval()'d code on line 11
   
       Attempt to read property "ID" on null in xxxxx/wordpress/wp-content/plugins/code-snippets/php/snippet-ops.php(504) : eval()'d code on line 11
       ```
   
 * I found the snippet that is causing the error – thanks to your help with the 
   search function 🙂
 * But now I’m stuck, cause I don’t know how to repair the snippet code – would 
   you mind helping me?
 * Here is the code:
 *     ```wp-block-code
       // Add featured image to RSS feed
       add_filter('the_excerpt_rss', 'j0e_imagetoRSS');
       add_filter('the_content_feed', 'j0e_imagetoRSS');
   
       function j0e_imagetoRSS($content)
       {
       $label = 'Tags: ';
   
       if (has_post_thumbnail()) {
       $content = '
   
   
       ' . get_the_post_thumbnail($post->ID, 'zuki-medium-portrait', array('style' => 'max-width: 100%; height: auto; margin-bottom: 10px;')) . '
       ' . $content .
       '
   
       ' . $label . j0e_show_tags() . '';
       }
       return $content;
       }
   
       // Creates the tags list
       function j0e_show_tags()
       {
       $post_tags = get_the_tags();
       $separator = ' | ';
       $output = '';
       if (!empty($post_tags)) {
       foreach ($post_tags as $tag) {
       $output .= 'term_id)) . '">#' . $tag->name . '' . $separator;
       }
       }
       return trim($output, $separator);
       }
       ```
   
 * It is the line with the “$post->ID” in it.
 * That would be really really kind 🙂
 * Thanks
   Heike
    -  This reply was modified 3 years ago by [HighKay](https://wordpress.org/support/users/hlorenz/).
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [3 years ago](https://wordpress.org/support/topic/php-error-583/#post-16596866)
 * Looks like some of that snippet is missing – specifically the part that creates
   the tag links. I’ve tried to recreate it where I can, and hopefully strengthened
   the code to prevent PHP errors.
 *     ```wp-block-code
       $callback = function ( $content ) {
       	if ( has_post_thumbnail() ) {
       		$thumbnail = get_the_post_thumbnail(
       			null,
       			'zuki-medium-portrait',
       			array( 'style' => 'max-width: 100%; height: auto; margin-bottom: 10px;' )
       		);
   
       		$tags = '';
       		$tag_objects = get_the_tags();
   
       		if ( $tag_objects ) {
       			$tag_links = [];
   
       			foreach ( $tag_objects as $tag ) {
       				$tag_links[] = sprintf(
       					'<a href="%s">#%s</a>',
       					esc_url( get_tag_link( $tag ) ),
       					esc_html( $tag->name )
       				);
       			}
   
       			$label = 'Tags: ';
       			$tags = $label . join( ' | ', $tag_links );
       		}
   
       		$content = $thumbnail . $content . $tags;
       	}
   
       	return $content;
       };
   
       // Add featured image to RSS feed
       add_filter( 'the_excerpt_rss', $callback );
       add_filter( 'the_content_feed', $callback );
       ```
   
 *  Thread Starter [HighKay](https://wordpress.org/support/users/hlorenz/)
 * (@hlorenz)
 * [3 years ago](https://wordpress.org/support/topic/php-error-583/#post-16597816)
 * [@bungeshea](https://wordpress.org/support/users/bungeshea/) – Thank you sooooooo
   much!!!!
 * That works perfectly 🙂
 * I really appreciate your fast & perfect support!
 * Thanks a lot 🙂
    -  This reply was modified 3 years ago by [HighKay](https://wordpress.org/support/users/hlorenz/).
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [3 years ago](https://wordpress.org/support/topic/php-error-583/#post-16597841)
 * Glad to hear!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘PHP error / eval()’d code’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

## Tags

 * [PHP 8.0](https://wordpress.org/support/topic-tag/php-8-0/)
 * [php-error](https://wordpress.org/support/topic-tag/php-error/)

 * 5 replies
 * 2 participants
 * Last reply from: [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/php-error-583/#post-16597841)
 * Status: resolved