Skip Navigation

[Resolved] Switch from grid view to list view

This support ticket is created 7 years, 3 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/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 7 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#545306

I am trying to:

Switch from Grid view to list view, with no page reload, in my Woocommerce customized Archive Page.

I visited this URL:

hidden link

and

hidden link

I expected to see:

a link at the bottom of the page switch the view, as u can see at the bottom of the page there is a Grid link in the List page and a List link in the Grid Page (at the bottom of the page)

I used this solution to make that but is not working

https://toolset.com/forums/topic/switch-between-list-grid-view-on-frontend/

Instead, I got:

It reloads the page into a not existing page.

#545448

Dear Raphael,

There isn't such a built-in feature within Views plugin, and the thread you mentioned above only works for normal view in a wordpress page, it won't work for wordpress archive, you can not setup two different URL for same wordpress archive.

In your case, I suggest you try the Views filter hook wpv_filter_force_wordpress_archive, for example,
1) setup two different Views wordpress archive,
a) one is grid layout mode, display a link to pass URL parameter: my-layout-mode=list
b) another is list layout mode, display a link to pass URL parameter: my-layout-mode=grid
2) When user click the link, it will pass URL parameter "my-layout-mode" to the wordpress archive,
use filter hook wpv_filter_force_wordpress_archive to check the value of URL parameter "my-layout-mode":
if it is "grid", return the ID of wordpress Views wordpress archive a)
if it is "list", return the ID of wordpress Views wordpress archive b)

More help:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_force_wordpress_archive
Filters the ID of the WordPress Archive to be used on a given archive loop.

#545627

Hi Luo,

I actually setup two different Views not WordPress Archives, anyhow I have to admin that I'm not so familiar with PHP, and thus I understand a bit how should be done, I have no idea on how to setup the filter.

Should I have to insert it into child theme's functions.php? I'm also a bit confused on how should I write the function.

Can you help me further?

#545877

As I mentioned above:
There isn't such a built-in feature, I suggest you try these:
1) setup two different Views
a) one is grid layout mode, put it in page A
b) another is list layout mode, put it in page B
2) In the page A ,add a link to page B
In the page A ,add a link to page B
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-link

It won't need any custom codes, but it will reload the page when you switch from one page to another.

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