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"]
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
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.
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.
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.
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?
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.