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?
- How to get home page ID?
- Creating a WordPress admin page without a menu for a plugin
- Adding Custom Fields for Img in Posts
- How To Ignore a Filter On Applying Filter the Content In a Function
- Shortcode display outside the div
- Pass $this to function nested in another public function of the same class
- change plugin shortcode function [closed]
- shortcode doesn’t work
- Calling shortcode in wp_localize_script strips result
- WordPress shortcodes & performance
- Is it possible to make shortcodes NOT case sensitive?
- Layout shop page: resize images and columns
- How to add inline css/js inside a shortcode
- How extend shortcode default values for a plugin?
- Shortcode in AJAX popup
- Looking for a solution – slightly convoluted problem
- Can I use a Shortcode output as an HTML attribute value?
- WP theme with Backbone
- Can wp_localize_script be used within a shortcode?
- Force [wordpress_social_login] shortcode to display where it is embedded [closed]
- How to generate CSS from a shortcode within a plugin
- Custom CSS for plugin form
- Show history of post revisions on front end
- Shortcode based chart plugin
- Plugin shortcodes not working in custom theme
- tag breaks shortcode output (other solutions don’t work)
- Input with spaces in Shortcode attributes overwritten by defaults
- Allow users of my plugin to define their own shortcode rather than use mine?
- WordPress Shortcode to get URL Parameters $_GET[‘name’] redirects for no reason at all
- WordPress function not being called from jQuery method
- creating html reusable blocks via shortcodes
- add_shortcode is not working in plugin where others are working
- Single API call exposed via shortcode with params
- SEO Friendly URL on dynamic product page produced via shortcode
- Making sure that a plugin’s scripts and stylesheets are included for dynamicaly loaded content
- Insert content of a post into another
- Some code in shortcode function being ignored
- plugin shortcode output
- How to Create a shortcode to this php function
- What is @Action in WordPress?
- Where are theme codes located for WordPress?
- Form that generates an ID for the customer
- How to have sample page for each new register users in a membership website
- using do_shortcode
- plugin shortcode not working on ajax request call
- Modify page title and subtitle with a plugin
- Shortcode not getting replaced
- How to activate a plugin on the activation of a theme?
- Add Shortcode tag in Widget/Sidebar
- WPTouch – how to remove shortcodes or make shortcodes function
- Custom shortcode for displaying user based on a role parameter
- WordPress Plugin Insert Html Code with Shortcode
- IF condition based on wp_remote_get output
- shortcode not return any thing in Gutnburg
- Shortcode Attributes to Return different $_POST
- Shortcode not working – quotes seems strange
- Get all the URLs of the pages that uses a specific shortcode
- Add the_post_thumbnail_url to a shortcode in function.php
- Form Plugin for Api Requests which is used via Shortcode
- Echo out element to another page.
- how to check if a shortcode is used more than one time in the same post
- Adding a Tag Parameter / Filter to My Shortcode
- Rename Smart YouTube’s httpv back to http for all posts
- How to use a shortcode or an application to dynamically embed content from one WordPress site to another?
- Managing and deleting transients with dynamically generated transient names
- Thumbnail image doesn’t show up in Shortcode output
- list of custom post by custom field in frontend
- get_post_meta shortcode returns empty field
- How do I use a plugin’s shortcode attribute value in another function?
- JS working when used normally but not in wordpress
- Make the product page as homepage WooCommerce
- WordPress Shortcodes – Return $Variable
- Shortcode function not showing up on mobile browser
- shortcodes not working [dt_carousel & [dt_fancy_image
- Shortcode generated widget to appear on same line as heading text and button
- Page takes on two different formats
- Sanitize AROUND shortcode
- Get not the full path
- Sending post data over REST API, how to parse shortcodes in post_content?
- Query Shortcode from a multisite to appear on a different site?
- Find all strings between an enclosing shortcode
- shortcode which is introduced into entry the blog, and appears in side bar
- Space in WordPress Attribute Causing Problems
- Shortcode registered from a plugin not recognized
- Strange get_the_* behavior with php 5.4
- How to load a plugin when doing an Ajax call? [duplicate]
- Convert usernames listed by the Groups plugin shortcode to displayed names?
- Creating Features List in WordPress Post
- Embedding BitBucket Code in Posting
- Do shortcodes affect page indexing by search engines?
- do_shortcodes() isn’t working
- How to show in front End images using Visual Composer attach_images?
- Seo Problems in My meta Discription [closed]
- I am experiencing difficulty fulfilling client request
- cURL External API request displays content above other content on page
- Beginner question: Accessing js script in plugin
- thumbnail_width not working in wordpress most popular post plugin
- Display file contents within Plugin