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: "https://wordpress.stackexchange.com/" } );
}
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" );
</script>
<?php
}
This will add the grid/list class to the product list immediately after it enters the document (as opposed to waiting for document ready).
Related Posts:
- How do I append lists in Prolog?
- Inorder Binary Tree Traversal (using Python)
- How to have a set of sets in Python?
- Learning Haskell: How to remove an item from a List in Haskell
- How to obtain a subarray in python 3
- Reversing a List in Prolog
- List Length in Prolog
- Archive list with only years and months
- Counting pageviews on high-traffic cached sites
- Gutenberg List Extension Block
- Editing a Post, 99% CPU?
- Similar posts formatting
- Introductory paragraph only in list of blog posts
- List all categories in options
- Create a list-style post of popular posts for the week?
- custom walker wp menu last element
- How to divide and display categories into two columns
- To get list of bottom most or deepest or last child for specified parent category
- How to display number of page views on a post?
- How to keep variable `$post` to using in another file
- Adding class to last list item? Not WP generated
- How can ι create my own (custom) WordPress table/list?
- Embed PDF into wordpress
- List first letter of categories – issue upon spcecial characters (danish letters)
- count the number of views of a post excluding own views
- How do I create an alphabetically organized glossary of links?
- Generate a nested list of all posts, sorted first by year, then by month
- adding a #hash to each link in list_pages()?
- Listing all sidebars
- How to fix blog article view and share #’s?
- How correct list-style displayed in firefox? [closed]
- Output categories in something different than a list
- Wrap Meta Box with and for each new line
- get_all_category_ids for bookmark
- Add thumbnails in ‘li’ list
- List products from current category
- How to add a box for list items?
- List plugins used in a WP site – guest, not admin [duplicate]
- Internet Explorer seperating lists differently in Twitter Widget Pro than all other browsers [closed]
- List child pages alphabetically
- How to make a text string into a bullet list [closed]
- ACF Plugin WP with list-group – Vimeo [closed]
- My WordPress website was hacked [closed]
- add_action in a custom plugin
- Add custom text color WordPress 3.9 TinyMCE 4 Visual editor
- ACF: post query, hide duplicate values [closed]
- archive_template override when no posts exist
- How can I modify admin bar only if my plugin is loaded
- Allowing users to Sign-up > Login > Post articles that need approval
- What is a good plugin for making a template that can be reused to make several objects on a single page?
- Hotel reservation plugin you would recommend [closed]
- Is there a plugin to turn comments into structured reviews [closed]
- standard custom page template hierarchy for plugins
- Adding custom meta boxes to specified custom post type
- WordPress – source link plugin – how to modify it?
- How do I make a shortcode to display the shop name on Dokan?
- Index.php using 100% CPU [closed]
- Automatic WordPress Clone Backup
- Adding a simple Javascript file with a plugin
- How to write to a separate PHP file in plugin settings
- Can’t Install/Upgrade Plugins Through WordPress
- hardcoded wp pages/plugins problems
- How to keep plugin (media-sync) running even the tab is closed?
- Load CSS before Theme CSS
- WordPress Media Library Folders + Custom Linux Server Hosting
- How does the WP repository determine that two plugins are the same when counting active installs?
- Visual composer custom element error
- Attempting to list all product categories and the price range of all products within them
- Is classical wordpress eidtor a good option for me to include a large table with a large number of images on my webpage?
- A dynamic table plugin to get user input
- Optimise wordpress database using SQL after deleting registered images from Media Folder
- What plugin would make this happen? If is the theme
- translate wordpress website from english to arabic
- how to add a hidden type input to wp admin login form programmatically
- Writing SEO for Homepage when homepage is set to display latest posts
- Plugin Options Page and Subpage
- wp rest api (v2) filter not working (404 error – rest_no_route)
- WordPress PHP error getting posts from another wordpress blog
- Returning incorrect $post->ID after installing plugin
- Plugin: Translated plugin is “not translated”
- ABSPATH doesn’t work
- How know the “admin” blog from wordpress multisite?
- Modifying WordPress XML-RPC Built-Ins
- wp_query for more fields plugin
- Get gallery and product gallery images full size
- contact 7 plugin stops some pages from working properly
- Disqus plugin outputs script as literal text
- WordPress “Categories to tag converter” not working on imported Blogger posts
- Changing appearance of WooCommerce product layout [closed]
- Shortcode return is printing a 1 afterward
- How to show total view count across all posts for an author
- How we add tabs in plugin page
- Custom booking form field not saving
- Woocommerce Emails not being sent [closed]
- How to register new elementor widget in functions.php
- Foreach retun in shortcode
- Plugin Option Fire Custom Function After Save
- My wp_update_nav_menu action is firing twice
- PHP – Unexpected character in input: ” (ASCII=20) state=0
- What is the best way to override functions of thirdparty plugins?