Skip Navigation

[Resolved] Inconsistent display of templates depending on items returned

This support ticket is created 5 years, 8 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.

Our next available supporter will start replying to tickets in about 1.68 hours from now. Thank you for your understanding.

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/Hong_Kong (GMT+08:00)

This topic contains 6 replies, has 2 voices.

Last updated by Luo Yang 5 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#1219289

I am trying to:
Show an archive for a CPT and it seems to function fine where there are items found. I am using a header, loop, and footer template in a wordpress archive set up with toolset and divi integrated.

Link to a page where the issue can be seen:
this link shows the page with several items returned. Notice the header and footer are shown. hidden link

However if the category is changed to one where there are no items returned, then the header and footer templates are not displayed.
hidden link

In my archive setup I am using the templates in the Output section:
[wpv-post-body view_template="pageheadertemplate"]
[wpv-post-body view_template="categorytemplate"]
[wpv-filter-meta-html]
[wpv-layout-meta-html]
[wpv-post-body view_template="pagefootertemplate"]

#1219384

Hello,

Thanks for the details, I can get your website credentials in your previous thread:
https://toolset.com/forums/topic/detail-template-not-being-used/#post-1215438

I am checking it in your website, will update here if there is anything found

#1219385

Here are what I found:

I assume we are talking about the WordPress Archive "Auctions, Categories":
hidden link

section "Output Editor", shortcodes:

[wpv-post-body view_template="pageheadertemplate"]
[wpv-post-body view_template="categorytemplate"]
...
[wpv-post-body view_template="pagefootertemplate"]

The shortcode [wpv-post-body] is for render post information(post content, fields, taxonomy), see our document:
hidden link
Outputs the content of the current post or renders a content template

But in the term's archive page you mentioned above:
hidden link
Since there isn't any posts(items) in the loop, so shortcode [wpv-post-body] won't display anything.

As a workaround, you can specific the post ID in shortcode [wpv-post-body], for example:

[wpv-post-body view_template="pageheadertemplate" item="43280"]
[wpv-post-body view_template="categorytemplate" item="43280"]
...
[wpv-post-body view_template="pagefootertemplate" item="43280"]

The ID "43280" is homepage ID, then it will be able to render the contents.

#1219691

I will give your solution a try. However; there is content that is shown in the post body in the form of the "no items found". It seems to me that this is a bug. Shouldn't the output section provide for the ability to have templates run when there is no content and also when there is? I didn't realize that the output section was only output for when there are returned items. Would be great if it could do both.

#1219779

Is there a shortcode to display a view template that does not require [wpc-post-body] ? In reading the wpv-post-body shortcode information you linked, the description states "Outputs the content of the current post OR renders a content template" Technically it only renders a content template if there is an item in the loop. Not the same thing.

#1220066

One additional problem with the workaround. It appears that I can't display the current category in the content template once at the top of the page?

#1220128

Q1) Shouldn't the output section provide for the ability to have templates run when there is no content and also when there is?

Yes, you can customize the text when there is no result, please edit the Views WordPress Archive:
hidden link

In section "Loop Editor", you should be able to find the codes:

	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]

There you can customize "No items found" to something else.

Same as above, you can customize when there is any result with shortcode:

	[wpv-items-found]
...
	[/wpv-items-found]

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-no-items-found
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-items-found

Q2) Is there a shortcode to display a view template that does not require [wpc-post-body] ?
No, there isn't other built-in shortcode to render Views content template, but you can add a feature request for it:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
Our developers will evaluate it

Q3) It appears that I can't display the current category in the content template once at the top of the page?
You can try another shortcode [wpv-archive-title], see our document:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-archive-title
This shortcode displays the title of the WordPress archive page.

For your reference.