WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any experience with Woocommerce Grid / List view plugin, I set to automatically start the list view but the problem is that while the page is loading initially opens a grid view and instantly change to list view, it takes 1 second but it seems confusing.Is there any idea how it could be resolved?

I took the code from the following link

share|improve this question
Where did you place that code? Do you get any JS errors? – TheDeadMedic Nov 8 '12 at 10:16
At the and of file: assets > js > jquery.gridlistview.min.js , and is working – Dime Nov 8 '12 at 10:21
up vote 0 down vote accepted

Undo any changes you've have made to the file, then add this at the top:

if ( jQuery.cookie( "gridcookie" ) != "grid" ) {
    jQuery.cookie( "gridcookie", "list", { path: "/" } );

Update: Sounds like a FOUC. Let's take a different approach - remove the code you added above & try adding the following to your theme's functions.php:

add_action( 'woocommerce_after_shop_loop', 'wpse_71885_shop_loop_list_init' );

function wpse_71885_shop_loop_list_init() {

<script type="text/javascript">
    jQuery( "ul.products" ).addClass( jQuery.cookie( "gridcookie" ) || "list" );


This will add the grid/list class to the product list immediately after it enters the document (as opposed to waiting for document ready).

share|improve this answer
I enter the code as you told me, but still the same problem appears – Dime Nov 8 '12 at 12:41
Try my second solution instead. – TheDeadMedic Nov 8 '12 at 14:05
Wow thanks man, finally works! – Dime Nov 8 '12 at 14:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.