Skip Navigation

[Resolved] Views Shortcode vs Views Block

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

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/Karachi (GMT+05:00)

This topic contains 5 replies, has 2 voices.

Last updated by Waqar 2 years, 10 months ago.

Assisted by: Waqar.

Author
Posts
#2295699
Bildschirmfoto 2022-02-17 um 19.16.31.png

Tell us what you are trying to do?
I made a video:
hidden link
If i placed the shortcode the grid is missing.
If i place block i cant handle it right cause i want to use one view with different filters.
So i want to use the shortcode.

And if place the view with the block and filter it like in the screenshot its not the widealign and no 4-grid-column.

What is the link to your site?
hidden link

#2296189

Hi,

Thank you for contacting us and I'd be happy to assist.

Based on your report, I was able to reproduce this on my test website as well. The view's grid loop styles are lost if it is loaded using the views shortcode.

I've shared these findings with the concerned team and will keep you updated on the progress through this ticket.

For now, a workaround can be to include some custom CSS code to make the view results show in the column layout.

The following CSS code can be included through generic site-wide CSS code section like WP Admin -> Appearance -> Customize -> Additional CSS:


div.four-column-view-cont .js-wpv-loop-wrapper > .tb-grid {
    grid-template-columns: minmax(0, 0.25fr) minmax(0, 0.25fr) minmax(0, 0.25fr) minmax(0, 0.25fr);
    grid-column-gap: 20px;
    grid-row-gap: 20px;
    grid-auto-flow: row;
}

div.three-column-view-cont .js-wpv-loop-wrapper > .tb-grid {
    grid-template-columns: minmax(0, 0.3333fr) minmax(0, 0.3333fr) minmax(0, 0.3333fr);
    grid-auto-flow: row;
}

After that, for a four-column grid, you can wrap the view's shortcode inside a div with class "four-column-view-cont":


<div class="four-column-view-cont">[wpv-view name="view-name"]</div>

And for a three-column grid, you can wrap the view's shortcode inside a div with class "three-column-view-cont":


<div class="three-column-view-cont">[wpv-view name="view-name"]</div>

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#2296215
Bildschirmfoto 2022-02-18 um 07.35.51.png

thx. for the post grid shortcode it works.

but i have 1 another things:
how it works when i place it with the view block as u saw in the screenshot attached? and u see in the post where u can find only 3 column.

#2298347

Thanks for the update and glad that it works.

My suggested workaround will be needed only for the case where you have to re-use a view using the view's shortcode (so that you can pass the shortcode attribute).

For the actual view that you have created using the view block, that CSS code won't have any effect.

#2299189

My suggested workaround will be needed only for the case where you have to re-use a view using the view's shortcode (so that you can pass the shortcode attribute).
So u wanna fix this in next versions? Cause the function is there to filter the view. Just dont work with css and grids.

So if use the shortcode how i can filter not only for special IDs also for custom post type or exlude posts IDs?

#2299573

Using the query filter option for the shortcode attribute, you can either include specific IDs or exclude specific IDs, but not both options at the same time. Also, it can't be used to filter the post types.

For complex query filtering requirements, you'll need to use the "wpv_filter_query" filter:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
https://developer.wordpress.org/reference/classes/wp_query/