elegantthemes / create-divi-extension

MIT License
186 stars 59 forks source link

How to get post ID of the currently edited page in visual builder when using shortcode in the text/code divi module #389

Open wpt00ls opened 4 years ago

wpt00ls commented 4 years ago

Problem Description

I've created a shortcode (am a 3rd party divi developer) that uses post ID as one of the attributes. If no post ID is supplied, the post ID of the current page is used.

When adding the shortcode (without the post ID attribute) to the divi text/code module in visual builder, I am unable to get the post ID of the page being edited currently.

It's due to a iframe request that divi visual builder makes http://mywebsitedomain.com/?et_pb_preview=true&et_pb_preview_nonce=0f1a73accf&iframe_id=et-fb-preview-1594791272692-634 . It triggers a new page request in WordPress and we loose the context of the page.

Ideally this request should include the post ID and also provide some hooks for developers to listen into (via javascript) before the iframe request is made.

Steps To Reproduce

  1. Open a page in divi visual builder.
  2. Add a text module
  3. Add shortcode in the textarea.
  4. This will make a doc type request (chrome inspector) originating from a programmatically created iframe.

Screenshot and/or gif

qWtu0oe3MR

lanresmith commented 3 years ago

@wpt00ls sorry I'm not able to reproduce this. Can you please confirm if you still experience this on the latest version of CDE?

cseevinck commented 3 years ago

Did you figure out how to get the post ID? I have the same problem.

grex22 commented 3 years ago

Confirming this as well - Add me to the list of developers who would love to be able to get the "current" post context (even just the ID) when editing in Divi builder.

lanresmith commented 3 years ago

@grex22 @cseevinck @wpt00ls can you pls try ETBuilderBackendDynamic.postId & let me know if it works for you?

gonperes commented 1 year ago

Any development on this? I would also like Divi Visual Builder to send the current Post ID through the iframe request. Otherwise, shortcodes that rely on the current post data cannot be previewed on Divi Builder. This looks like an easy change to be made.

thelanj commented 2 months ago

Anyone figure this out?