Try using this:
$post_id = get_the_ID();
OR
global $post;
$post_id = $post->ID;
OR
$post = $wp_query->post;
$post_id = $post->ID;
Related Posts:
- Get Image Having the ID [closed]
- Is there a function to search for a wildcard value when calling a shortcode?
- Custom Shortcode Broken in WordPress 3.1
- Use $_GET inside a shortcode print empty Array
- Namespaced shortcode?
- Where are theme codes located for WordPress?
- My plugin won’t return anything [closed]
- Anyway to convert a plugin to become a shortcode?
- Form that generates an ID for the customer
- Render Modula Plugin Shortcode On Ajax Request
- Shortcode to update user meta
- Why shortcode always displayed after footer not in body
- How to have sample page for each new register users in a membership website
- How can I run a custom shortcode function on a live site and only run if the viewer is a specific machine?
- using do_shortcode
- Why am I unable to load scripts in head in plugin?
- How to add a dvi tag to a shortcode then change a generated text using jQuery
- Deactivate JS Script in Plugin Shortcode
- plugin shortcode not working on ajax request call
- Displayed content disappears when adding attributes to shortcode
- Modify page title and subtitle with a plugin
- How do I pass custom shortcode-extracted variables (taxonomy) into a query function for WordPress RoyalSlider?
- Where to find the code used to render a page that has a shortcode and a template defined?
- Shortcode not working after move wordpress website files
- Set post tags using tag ID
- Shortcode not getting replaced
- How to activate a plugin on the activation of a theme?
- Add Shortcode tag in Widget/Sidebar
- Flipping Book PHP Code? Any experience?
- WPTouch – how to remove shortcodes or make shortcodes function
- convert more tag to shortcode
- Shortcode does not expand in Facebook like
- Plugin that provides the [edit] shortcode?
- Custom shortcode for displaying user based on a role parameter
- WordPress Plugin Insert Html Code with Shortcode
- Return multiple values in a shortcode attribute
- IF condition based on wp_remote_get output
- shortcode not return any thing in Gutnburg
- Shortcode Attributes to Return different $_POST
- How to change shortcode’s default theme?
- Override/ignore CSS from active theme as not to interfere with my custom CSS
- Is there a way to convert shortcodes to html content?
- Shortcode not working – quotes seems strange
- Get all the URLs of the pages that uses a specific shortcode
- How to use template inside plugin shortcode with variables for big HTML code
- Get param from shortcode in plugin function
- shortcode – multiple instances of same parameter name in one shortcode instance
- Function call in wordpress short code handler fails
- strange shortcode error: does shortcodes requires any dependency?
- Loop returns the current page’s permalink and guid instead of the post in the loop
- Inserting shortcode in href – any ideas or workarounds?
- wp_localize_script not passing the data
- Add the_post_thumbnail_url to a shortcode in function.php
- Search by Attachment ID
- Get post content from outside the loop with plugin shortcode usability
- How to rewrite URL and get the values?
- Is there a good way to load tiny_mce_popup.js through editor.windowManager.open?
- How to prevent tabs from opening all at once
- Executing Javascript in Plugin
- Form Plugin for Api Requests which is used via Shortcode
- Echo out element to another page.
- Load CSS files in header of Bones theme?
- Shortcode and variable
- Is there any way to inject text onto pages?
- How can I achieve this, using shortcodes
- Create Short code dynamically
- Get variable value based on string constant
- how to check if a shortcode is used more than one time in the same post
- Adding a Tag Parameter / Filter to My Shortcode
- Filters on the_content with plugins, pages and shortcode
- Which is a better practice when writing shortcodes: pack lots of configuration parameters or just give an id?
- grab or load text on demand
- How can I replace content on site generated from plugin without changing plugin
- Rename Smart YouTube’s httpv back to http for all posts
- Elementor Pro display featured image on section -> style -> image using shortcode
- Creating New Dynamic Fields for a Certificate (Number Generation, Code Referencing, and more)
- Help understanding dynamic endpoints based on where a shortcode is used
- How To Use do_shortcode with WooCommerce One Page Checkout
- How to use a shortcode or an application to dynamically embed content from one WordPress site to another?
- WordPress load same script two times
- Managing and deleting transients with dynamically generated transient names
- how to display a template.php in a shortcode
- How to get current cart values using WC_Shortcodes?
- Give custom page template a custom post ID
- Bookmarking custom template pages which all have the same page ID
- Can I add Short Code Of A Plugin In The Code Editor of WordPress?
- Thumbnail image doesn’t show up in Shortcode output
- list of custom post by custom field in frontend
- insert og image link in wordpress post
- get_post_meta shortcode returns empty field
- Custom Post Type with Sequence ID
- Get a value from a shortcode for another function
- How do I use a plugin’s shortcode attribute value in another function?
- How to check if short code is present in template?
- Shortcode do not return the right data in post
- How to call function in WordPress on button click?
- Why does my custom plugin only function correctly once per page?
- Hide content for specific users with id
- Why is my shortcode not working?
- JS working when used normally but not in wordpress