Skip Navigation

[Resolved] [wpv-post-id] does not work with DIVI

This support ticket is created 4 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Tagged: 

This topic contains 11 replies, has 3 voices.

Last updated by Pat 4 years, 3 months ago.

Assisted by: Waqar.

Author
Posts
#1418303

Pat

Hello,

I have created a site using Toolset and Divi and found a strange issue :
I have built a template for a postype (thanks to Divi builder) and inserted the [wpv-post-id] shortcode.
Looking at the result, it seems that what is returned is not the ID of the post but the ID of the Divi Theme Builder Layout

Are you aware of this and what can I do to move forward as I need to retrieve the right info in this page.
Regards
Pat

#1418355

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Pat

It looks like the Divi Theme Builder is interfering with the global $post object which identifies the current post.

Instead of the Views shortcode, try registering this custom shortcode:

add_shortcode('postid', function ($atts = [], $content = null) {

    global $post;
    return $post->ID;
});

Then add that 'postid' shortcode to your template.

What does it output?

If it outputs the ID of the Divi Theme Builder Layout, then that's the problem, and it would only be Divi that can do something about that, you should report it to them.

Lots of 3rd party software would rely on the $post object being correct, not just Toolset.

#1418381

Pat

Hi Nigel,

That's far much better like this !
Thanks.
I still have an issue as I need to use the info inside a map and here is what I have placed as code in the Divi Template :

[wpv-map-render map_id="map-1" map_width="100%" map_height="300px" scrollwheel="off"][/wpv-map-render]
[wpv-map-marker map_id='map-1' marker_id='marker-6' address='[types field='localisation' item='[postid]'][/types]'][/wpv-map-marker]
I have also tried this as marker :
[wpv-map-marker map_id='map-1' marker_id='marker-7' marker_field='wpcf-localisation' item='[postid]'][/wpv-map-marker]

'localisation' is an address field that is integrated inside the post that is displayed thanks to the Divi template.

In both cases, nothing is displayed (the map is without marker).
Regards
Pat

#1420837

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Checking the documentation for the wpv-map-marker shortcode, it still lists id rather than item as the attribute to set the post from which the address field is pulled.

Without testing myself, you could try updating your shortcode to use the id attribute, like so:

[wpv-map-marker map_id='map-1' marker_id='marker-7' marker_field='wpcf-localisation' id='[postid]'][/wpv-map-marker]

If that doesn't work I would try the map on a page that you don't design with the Divi themer to verify that it works in that case, so that the problem can be narrowed down.

#1421821

Pat

Hi Nigel,

Thanks for your help.
I have tried to place it inside Divi builder without success.
I have also integrated it inside a post and got the same issue?
If I use a the post ID (ie : 1164) instead of the shortcode, then this is working !

Regards
Pat

#1424407

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Pat,

Thanks for writing back.

Nigel is on holiday and will be back on 2nd January, so I'll be following up on this ticket.

Can you please share temporary admin login details, along with the details about the page/post and the template where you tested this map marker shortcode?

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

regards,
Waqar

#1425713

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for sharing the admin access.

I can see the issue on your website, but couldn't reproduce this on my test website.

On my website, with the same Divi theme (4.0.6) I was able to get the correct current single post's ID using the "wpv-post-id" shortcode when used inside a text module in a theme builder template.

Not only that, the map and the marker also worked as expected without even passing the post ID.

Example:


[wpv-map-render map_id="map-1"][/wpv-map-render]
[wpv-map-marker map_id='map-1' marker_id='marker-1' marker_field='wpcf-book-location'][/wpv-map-marker]

This suggests that this issue is something specific to your website. I'll recommend testing this with all non-Toolset plugins temporarily disabled. If the issue is fixed, you can start adding the disabled plugins, one-by-one, to narrow down to a possible conflict.

In case the issue still persists, I'll need a clone/snapshot of your website, to investigate this in more depth.
( ref: https://toolset.com/faq/provide-supporters-copy-site/ )

Note: Your next reply will be private.

#1425809

Pat

Waqar,

I have looked at the template and currently, I'm able to display the address field (localisation) in the table above the button in the right), but the same field used as an address in the Toolset map marker does not works !

Regards
Pat

#1426145

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Pat,

Thanks for the update and yes I also noticed the same strange behavior on your website.
( this is why I requested a clone/snapshot because the same can't be reproduced on a fresh install )

I've set your next reply as private and feel free to share the duplicator package, whenever you get a chance.

regards,
Waqar

#1427617

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for sharing the duplicator package and I've managed to successfully deploy it on my server.

I'll be performing some tests on it and will update you with my findings, once it completes.

Thank you for your patience.

#1434153

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Pat,

Thank you for waiting.

During testing on your website's clone and on my own website, I was only able to reproduce these issues, when I used the Divi theme's copy from your website.

Looks like some changes were added to the file(s) in the Divi theme folder.

To fix this, I'll recommend making a backup copy of your existing Divi theme folder and update it to the latest version (4.0.9) and this issue with the map marker and the incorrect post ID will be automatically fixed.

After that, if you'd like to add back any changes to the Divi theme files, you can create a child theme and then apply those changes through that ( the actual files in the parent theme folder shouldn't be edited, as they get overwritten, when theme updates ).

Here is a useful guide on the topic:
hidden link

I hope this helps and please let me know how it goes.

regards and a Happy New Year,
Waqar

#1438017

Pat

Hi Waqar,

Sounds good. For any reason (?), the Divi theme I was using seems to be corrupted.
I changed to the new one and that's OK
Many thanks
Pat

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.