Sauter la navigation

[Résolu] Content template using the ID of Divi Template not ID of the viewed page

This support ticket is created Il y a 2 semaines et 4 jours. 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Ce sujet contient 3 réponses, a 1 voix.

Dernière mise à jour par Minesh Il y a 2 semaines et 1 jour.

Assisté par: Minesh.

Auteur
Publications
#2802700

Tell us what you are trying to do?
I've been using Toolset with Divi theme for a long time, and I am testing Divi 5 with Toolset.
Divi has a Theme Builder which you can use to set up specific post types or archives. Sometimes I call Views Fields or Content Templates from inside the Theme Builder templates.

If I call a view with the views shortcode this works as it should.
e.g. [wpv-view name="related-cab-view"]

If I call a content template or a field it treats the Divi Template as the post that's being queried.

E.g. [wpv-post-title] shows "Theme Builder Layout"
If I use [wpv-post-title item="390"] where 390 is the post id I get the correct post title.

I filed a bug report with Divi Support saying it's working different from Divi 4, but their reply was:
"This is correct and the intended behavior, since the Theme Builder template is actually a layout as well and that's the $post that's in the WordPress loop."
and:
"Yes, in Divi 4 it's currently broken/not working as expected (even if it shows the title of the post - which is what you would expect it to do - but this isn't the correct behavior, as per the WordPress codex)."

Note that I've made workaround by making a shortcode the get_queried_object_id() and can use that in [wpv-post-title item="[queried_object_id]"] from within other Content templates, but not directly from the Divi Template (the shortcode within a shortcode doesn't resolve as it does in a Content Template or view).

I just wondered if there is an inbuilt way to make it select the post ID from get_queried_object_id() rather than from get_the_ID(), or a way to add the queried object ID to the Post Selection options.

#2802826

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Normally, you can reference the post ID with any types shortcode using the "item" attribute and you can pass the [wpv-post-id] shortcode.

For example:

[wpv-post-title item='[wpv-post-id]']

if you check on frontend it should display the correct post title, I'm not sure about the backend.

#2802955

Hi Minesh

As per my initial post, all shortcodes and content templates are using the $post which is the Divi Template (as the Divi Template is in the loop) and not the $post that is being shown.

So [wpv-post-id] gets the ID of the Divi Template not the queried object.

I understand why the default for these is to get the post in the loop, because they have to work inside a view, but I thought there might be a way for it to use get_queried_object_id() instead of get_the_ID()

Is there a way I can add an extra option to the "Post Selection" list where you can choose from:

The current post being displayed either directly or in a View loop
The parent of the current post in the same post type, set by WordPress hierarchical relationship
A post related to the current post, set by a Types relationship
The post owner of the Types repeatable group field
A specific post (search by title)
A specific post (set by post ID)

to allow it to select "The Queried Object"
.

#2803380

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

Well - all those options are used when you display the view on frontend.

There is no such feature available to get the ID of post while using Divi builder instead of Divi's template ID.