I've a big problem with my code in my functions.php in Wordpress. There is something strange. It's working fine but every load I got a warning in my debug.log.
My code:
add_filter( 'the_content', 'add_id' );
function add_id( $content ) {
global $post;
echo $id = $post->ID;
$content .= $id;
return $content;
}
Log:
[17-Oct-2018 15:53:18 UTC] PHP Notice: Post was incorrectly called . Product features should not be accessed directly.
I've tried all known ways to get a product but every time I get this error. What si wrong here?