Title: [Plugin: Shortcodes Pro] Get post ID
Last modified: August 20, 2016

---

# [Plugin: Shortcodes Pro] Get post ID

 *  Resolved [James Roberts](https://wordpress.org/support/users/james-roberts/)
 * (@james-roberts)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-shortcodes-pro-get-post-id/)
 * Hi Matt,
 * First off, great work on Shortcodes Pro, it is proving to be a very handy tool.
   I have just one question, in the custom PHP code section of the UI, can I get
   the post_id of the current post? I have tried using $content[‘ID’] but with no
   luck, is there some built in var with the post info that can be used? I need 
   to do this as I am running an SQL query in my shortcode and the where clause 
   needs to take in the current post ID. Hope all that makes sense.
    Thanks again
   for such a cool plugin 🙂
 * Kind regards,
    James Roberts.
 * [http://wordpress.org/extend/plugins/shortcodes-pro/](http://wordpress.org/extend/plugins/shortcodes-pro/)

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

 *  Plugin Author [Matt](https://wordpress.org/support/users/sksmatt/)
 * (@sksmatt)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/plugin-shortcodes-pro-get-post-id/#post-3036191)
 * Hi James,
 * Thank you. From the top of my head, I think you should try passing the ID as 
   an attribute. Not sure really if there is a safer way.
 * Kind Regards!
 *  Thread Starter [James Roberts](https://wordpress.org/support/users/james-roberts/)
 * (@james-roberts)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/plugin-shortcodes-pro-get-post-id/#post-3036193)
 * Thanks for the reply Matt,
 * Am I correct in saying to do this the user would need to know the post id as 
   it would need specifying to get passed as an attribute? Not sure that this would
   be a solution as the folks who will be using the shortcode in this case are anything
   but computer literate so I was hoping I could set it up so when they click the
   button, the shortcode would get the current post id (I assumed this could be 
   accessed in some built in var) and the rest of the code would run returning some
   HTML with data got from SQL queries using the post ID in the where clause. Does
   this sound possible?
 * Kind regards,
 *  Thread Starter [James Roberts](https://wordpress.org/support/users/james-roberts/)
 * (@james-roberts)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/plugin-shortcodes-pro-get-post-id/#post-3036194)
 * Hi Matt,
 * I just tried adding an attribute but when I click “Add Attribute” in the popup
   window nothing happens, also when I change the type to select I dont get any 
   options to add, am I missing something?
    My apologies if I am just being daft
   🙂
 * Kind regards,
 *  Thread Starter [James Roberts](https://wordpress.org/support/users/james-roberts/)
 * (@james-roberts)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/plugin-shortcodes-pro-get-post-id/#post-3036212)
 * Any input fella?
 * Thanks,

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

The topic ‘[Plugin: Shortcodes Pro] Get post ID’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/shortcodes-pro_434343.svg)
 * [Shortcodes Pro](https://wordpress.org/plugins/shortcodes-pro/)
 * [Support Threads](https://wordpress.org/support/plugin/shortcodes-pro/)
 * [Active Topics](https://wordpress.org/support/plugin/shortcodes-pro/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shortcodes-pro/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shortcodes-pro/reviews/)

## Tags

 * [custom php](https://wordpress.org/support/topic-tag/custom-php/)
 * [Post_ID](https://wordpress.org/support/topic-tag/post_id/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 4 replies
 * 2 participants
 * Last reply from: [James Roberts](https://wordpress.org/support/users/james-roberts/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/plugin-shortcodes-pro-get-post-id/#post-3036212)
 * Status: resolved