Title: Undefined variable: attachment_id
Last modified: January 10, 2021

---

# Undefined variable: attachment_id

 *  Resolved [BenLinders](https://wordpress.org/support/users/benlinders/)
 * (@benlinders)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/undefined-variable-attachment_id/)
 * I see the below message all across debug.log:
 * Jan 10, 16:42:36
 * Notice: Undefined variable: attachment_id in /home/public/sites/www.benlinders.
   com/wp-content/plugins/contextual-related-posts/includes/media.php on line 245
 * Any idea what causes this?
 * Ben Linders
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fundefined-variable-attachment_id%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/undefined-variable-attachment_id/#post-13888624)
 * Thanks for flagging [@benlinders](https://wordpress.org/support/users/benlinders/)
 * I’ll fix this in v3.0.3.
 *  Thread Starter [BenLinders](https://wordpress.org/support/users/benlinders/)
 * (@benlinders)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/undefined-variable-attachment_id/#post-13888852)
 * Thanks Ajay!
 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/undefined-variable-attachment_id/#post-13888947)
 * [@benlinders](https://wordpress.org/support/users/benlinders/)
 * I released v3.0.3 which should fix this now. Please can you check and verify 
   this is the case.
 *  Thread Starter [BenLinders](https://wordpress.org/support/users/benlinders/)
 * (@benlinders)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/undefined-variable-attachment_id/#post-13889010)
 * Update installed, no new errors appearing and related posts are being shown.
 * That was quick, thanks Ajay!
 *  Plugin Author [Ajay](https://wordpress.org/support/users/ajay/)
 * (@ajay)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/undefined-variable-attachment_id/#post-13889026)
 * You’re welcome and thanks for confirming.

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

The topic ‘Undefined variable: attachment_id’ is closed to new replies.

 * ![](https://ps.w.org/contextual-related-posts/assets/icon-256x256.png?rev=2985705)
 * [Contextual Related Posts](https://wordpress.org/plugins/contextual-related-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contextual-related-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contextual-related-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/contextual-related-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contextual-related-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contextual-related-posts/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Ajay](https://wordpress.org/support/users/ajay/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/undefined-variable-attachment_id/#post-13889026)
 * Status: resolved