Skip Navigation

[Resolved] Can I create a View without using a loop?

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

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 7 replies, has 2 voices.

Last updated by damianS-2 7 years, 2 months ago.

Assisted by: Beda.

Author
Posts
#483131

Hello,

I have a block of conditional code here:

<div class="person-excerpt-title">[types field='title'][/types]</div>

[wpv-conditional if="( has_term('Advisory Council', 'people-category', null) eq '1' )" ]
<p>[types field='job-title'][/types]</p>
[/wpv-conditional]

[wpv-conditional if="( has_term('Board', 'people-category', null) eq '1' )" ]
<p>[types field='job-title'][/types]</p>
<a class="fusion-button button-flat button-round button-large button-default button-1" style="width: 100%;" target="_self" data-toggle="modal" data-target=".[wpv-post-slug]"><span class="fusion-button-text">LEARN MORE</span></a>
[/wpv-conditional]

[wpv-conditional if="( has_term('Faculty', 'people-category', null) eq '1' )" ]
<p>[types field='job-title'][/types]<br />
<strong>Department(s):</strong> [types field='department' separator=', '][/types]</p>
<p><a class="fusion-button button-flat button-round button-large button-default button-1" style="width: 100%;" href="[wpv-post-url]" target="_self"><span class="fusion-button-text">LEARN MORE</span></a></p>
[/wpv-conditional]

[wpv-conditional if="( has_term('Staff', 'people-category', null) eq '1' )" ]
<p>[types field='job-title'][/types]<br />
<strong>Phone:</strong> [types field='phone'][/types]<br />
<strong>Email:</strong> [types field='e-mail-address'][/types]</p>
[/wpv-conditional]

[fusion_modal name="[wpv-post-slug]" title="Bio" size="large" background="rgb(34, 34, 34)" border_color="" show_footer="no" class="" id=""]

[types field='bio'][/types]

[/fusion_modal]

And I am hoping I can contain it in a view that looks more like this:

[wpv-view name="view-for-people-excerpts"]

However.. When I go to build the view, I see that I have to use the loop. Is it possible to build a View without a loop? Or can I build a loop with just this one code block in it?

Thanks,

Damian

#483133
Screenshot 2017-01-28 16.28.58.png

Hi again,

I have a more urgent problem directly related to this topic.

I am trying to use the code block in the first post in the Excerpt field, so that I can display conditional shortcodes in excerpts on multiple kinds of overview pages.

However, the shortcodes nested inside the conditional statements are rendering as plain text, and not getting processed as shortcodes.

See attached screen shots... The conditional statements are working, but the nested elements are not.

Is there any way of making this work?

Thanks

#483193

1. Is it possible to build a View without a loop?

No, that's the exact purpose of the View.
It creates a Loop of Posts, according to the Query you create.
It's like a Loop in WordPress native Themes, that also will always create a list of Posts.

2. Excerpts are stripped by default from WordPress.
https://developer.wordpress.org/reference/functions/the_excerpt/

Maybe this Post can help you create a Custom Excerpt:
http://wordpress.stackexchange.com/questions/141125/allow-html-in-excerpt

But I rather suggest to add a WYSIWYG Field and use that as "the excerpt", as then Views will handle it like a Post Body (where HTML and Shortcodes will work just fine)

#483359

Good information, thanks.

In this case I'm using Avada and Fusion Builder, and I'm afraid that I would have to rebuild the entire Blog shortcode, to get in there and replace the Excerpt with a custom WYSIWYG field.

Is that what would be required to use a custom excerpt?

#483529

Well, a Custom Excerpt created with a WYSIWYG would be nothing else but a Types Field (WYSIWYG) rendered somwhere in the Post or page template (Content Template)

A full Custom Excerpt using the WordPress Excerpt API would require editing the Template to actually output the new excerpt, or perhaps a new ShortCode that outputs your customized Excerpt.

I would go with the WYSIWYG Types Field, wich is easy to insert in a Content Template as example.

We offer integration with AVADA BTW 🙂 :
https://toolset.com/documentation/user-guides/toolset-avada-integration/

#483836

Thank you Beda. Very helpful.

You mention Avada integration -- however, I don't see how I can easily replace a custom field in the Avada Blog shortcode, for instance, without rebuilding the entire layout in a Content Template/View.

Is there an easier way to integrate with Avada Shortcodes that I am missing?

#484063

Our integration helps to use Layouts on AVADA Theme.
I mentioned it because you might be interested.

But it will not help to acheive the Custom Solution you need, that will require either Custom Code or a rebuild of your Template, if you need to display the WYSIWYG.

The issue with Excerpts not accepting ShortCodes is due to WordPress, and we cannot change that.
But Toolset can help to display the WYSIWYG anyhwere on site, or any other field, if you need.

#486021

Got it, thanks.

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