2

I can identify if in preview mode or not easily by calling is_preview().

I can also get the id of the post being previewed by calling get_the_ID().

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.