Its an old question however would like to answer for other people
Within ajax function hooked to wp_ajax do this.
$url = wp_get_referer();
$post_id = url_to_postid( $url );
Related Posts:
- Ajax posts filter by date, comments, top views, top likes
- Send post id through ajax and get the post content back
- AJAX load more posts not using correct category and repeating the same few posts
- How to get posts from network blog
- Ajax calls in wordpress
- How to change the case of all post titles to “Title Case”
- Function to execute when a post is moved to trash .
- How to make comments work for a post loaded per Ajax?
- Ajax Load More Posts in Category Page
- Fatal error: Call to undefined function post_exists()
- How to publish a post with empty title and empty content?
- How do I use element instead of tags in WordPress post content having webP support?
- How to use oEmbeds on Post Content during AJAX requests
- Show Custom Taxonomy Categories, Listing of Posts, and Single Post via AJAX
- Keep a fluid max number of posts on site
- How to add an admin function only to posts, not pages?
- Human Time Diff, change mins to minutes
- How to get new post URL?
- POST from jQuery to PHP
- How to Display Post View Count
- Remove double space after a period
- When paginating a Page with the tag, how can the 2nd and subsequent page styles be customised?
- The correct way to call posts with ajax
- Hiding posts in a list from specified categories
- Run a function when post is deleted?
- Checking is user author of number of posts?
- Create cron job without a plugin?
- AJAX filter posts by year
- How to rename “Publish” metabox title in post screen
- Add icon/badge next to posttitle of specific category
- Add ajax load more function using WP API
- How to pass Post_ID variable from theme’s Single.php to custom Plugin using AJAX
- Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
- Ajax load more button in Recent posts widget
- Exclude category from
- Show the content that is after the excerpt using child theme
- How to allow users to post only in certain category and hide elements from edit page?
- Can’t get buddypress notifications in front-end; why do I get this error?
- How do I display some posts fully on the homepage, and some as an excerpt only?
- Genesis + Ajax + Jquery | Failling to call action
- Random ajax load only works with posts_per_page set to -1
- Using ajax on editing a category edit page?
- Force authors to Preview a post before publishing
- Order posts alphabetically: how to set order=asc in mysql query?
- Change all author links in Blog roll
- Format latest/newest post differently
- is_page Funtion for Posts ?
- Post type no single page
- Adding a user’s ID behind the tag ref link address
- Lock post editing to one user at a time – wp_check_post_lock
- Isn’t the way posts are displayed very unefficient?
- How to check in functions.php if there is data in a WP_Query?
- restrict incrementation of post vies count when refreshing the page
- WordPress notification if new post published
- Where Should i write the code for wordpress ajax voting?
- Call current post URL in ajax
- Get post by tag
- Related Posts function not working
- the_content() Not Grabbing All Content
- Query function not executed between element [closed]
- saving/reading custom field value does not work – no value gets POSTed
- Internal linking to posts permalink fail because of spaces and stripe at postname
- Have h2 tag not show up if there are no blog posts
- WordPress as CMS: How to manage/handle images assigned to a post as full-sized background images in a slideshow?
- How to implement a WordPress comments function?
- How to add content above footer in posts from specific category
- How to make ajax load posts from the current category?
- How to put the author of the post in the comments?
- Check if almost 10 year old – working code is up to date
- How to add a custom class attribute into code wrapper? [duplicate]
- Passing values via an Ajax querystring
- How to create custom search form function including post “tags”
- how to filter posts by category without page load (ajax) in wordpress?
- WP Ajax returning 0, can’t find action
- Remove pagination if search returns empty
- Remove HTML tags from all posts
- call to jquery ajax failing with 500 error when passing extra data field
- Post data across WordPress sites
- Save All Post Permalink From A Specific Category into a .txt file
- Ajax post doesnt call succes after got the response
- How to Display Most View Post in the template file?
- Colorbox not working on native WordPress gallery when gallery is loaded thru AJAX
- Dynamically load posts based on category
- Show post excerpt
- How do I apply a wordpress function to something with no ID inside an archive page?
- Show author bio box
- Display author bio box
- Check if user has avatar
- Call image from post on index page?
- How do I get thumbnails?
- Run function after post is updated
- When Author add new post change default status to pending
- fire action when post is being edited as well as saved?
- Get post id on click of thumbnail
- Getting rid of the blog page entirely
- List direct children of page
- Notify Author of the post if admin deletes his post and perform some function
- Show Next/Previous without Link
- Filters do not work when there are multiple (one works)
- WordPress Ajax load doesn’t work