I can identify if in preview mode or not easily by calling
I can also get the id of the post being previewed by calling
The return value of the
get_the_ID() is not consistent and here is where I seek for advice.
If the post has not been published yet, the ID returned is always correct and links to a row in the database with the exact content being previewed.
If the post has been saved as draft OR published, the ID returned is of the parent post. However, it is not clear how to get the ID of the row in the database from where the preview content is actually retrieved. Any ideas how to get the ID of the actual row being displayed?