WordPress.org

Forums

Shortcodes Pro
[resolved] Get post ID (5 posts)

  1. James Roberts
    Member
    Posted 2 years ago #

    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/

  2. Matt
    Member
    Plugin Author

    Posted 2 years ago #

    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!

  3. James Roberts
    Member
    Posted 2 years ago #

    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,

  4. James Roberts
    Member
    Posted 2 years ago #

    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,

  5. James Roberts
    Member
    Posted 2 years ago #

    Any input fella?

    Thanks,

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Shortcodes Pro
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic