Skip Navigation

[Résolu] Content template in Wordpess Archive

This support ticket is created Il y a 4 années et 8 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 5 réponses, has 2 voix.

Last updated by arisG Il y a 4 années et 6 mois.

Assisted by: Beda.

Auteur
Publications
#1301919

Hello,

we have the following code in Loop editor of a WordPress Archive.

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
		<wpv-loop>
          <div>Test Home/Blog</div>
		</wpv-loop>
	<!-- wpv-loop-end -->
        [/wpv-items-found]
[wpv-layout-end]

For some reason, if we add a content template outside the <wpv-loop> the content template is not displayed. Until recent, the content template was displayed even if it was outside [wpv-layout-start]

I have provide access to our staging environment. You can check the Homepage

Thank you

#1301929

There is a PHP error that alters the query, and that can of course break Archives as well:

Notice
: Undefined index: query in
/plugins/lagonika-secondary-menu/assets/lagonika-secondary-menu-core.php
on line
47

I recommend resolving that error.

Relate to displaying content, you can always test simple strings:
Do simple strings show outside the [wpv-layout-start] ShortCode?
We see they do, so it may be either an issue with all ShortCodes or just the Content Templates.
It seems it's just the Content Template since [wpv-etc] (other shortcodes of Views) work fine.

I can also confirm this locally, on archives Content Templates seem to fail if placed outside the loop.
They work fine in Views though.

I think this is because something's overwritten (post object) or not present as expected in archives.

In fact, in Toolset Views there is an issue very similar to the one you experience here:
hidden link

I think it is the same cause, but will, in any case, escalate this issue and check if it's the same or needs a new report to the developers.
Right now there is no other way but to paste the content you have in the CT directly into the Archive, but be aware that several things requiring a Post ID will never work outside the loop (even not, if CT's would display their content)

#1301933

Hi Beda,

this is something that starts suddenly. When we develop this solution everything works fine with the content template outside the loop. We noticed it today but 1-2 months before it works. Maybe after an update of Toolset. Furthermore, it's strange that it works in views and not to WordPress Archives.

Our content templates where we want to add outside the loop are not possible to add them directly in Archive. They use Avada fusion builder and they are big.

Regards

#1301935

I understand, however, right now there is no solution for it.
The issue is very likely due to the problem I mentioned (which as well went worse exactly with one of the latest updates)

I will keep you in the loop here about the progress, eventual solutions and/or fixes.

#1301937

As suspected, it's due to the missing post outside that loop (there are no posts outside a loop and Views usually fakes one to display Content Templates)

Now - since you are aware that displaying data about "current" post is not possible anyway outside the loop I assume your content template does not call any post data without at least passing an ID to the shortcodes or does not have any such shortcode at all.
Then, you can avoid the issue by faking a Post yourself (just never call post content in the template, if you do so, as then it'd display data of that fake post)

For example, you can create a dummy empty post and call that when inserting the template:
[wpv-post-body view_template="your_template" item="1"]
Item will be the Post ID of the dummy post, in my case hello world.

But since the content template is styled and displaying if any only particular posts data (I hope, because otherwise, it will never work properly), you can use above solution, it will render your template (but the post data of it will be of the Post you pass in item attribute).

Note that this will be the same once we fix it:
Outside the loop you cannot display particular post data, unless passing an ID to the ShortCodes (in the Content Template)

I'll keep you updated on the progress.

#1350039

Hello Beda,

we finally resolve our issue with the solution that you mention (dummy empty post and content template with post id)

Thank you!

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