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]
- Keep the expansible tree (list of posts) open in the sidebar
- How to see which sites use my installed plugins (wordpress multisite)
- Product count in archive page Title in WooCommerce [closed]
- Use current class method inside add_submenu_page()
- how remove font to increase site speed load
- Plugin main file is constantly been fired on every website visit
- Why is Google Search Console getting X-Robots-Tag noindex?
- Website show Google Ads when we have no Google Ads linked to our website
- How to set “split_on_numerics” to false in ElasticSearch mapping using ElasticPress? (for proper SKU search in WooCommerce) [closed]
- Sticky option for custom post types without using custom fields or plugins
- My plugins are ending up above the header?
- Let users sell video in my website [closed]
- Change letters for day name
- Where should custom post types be registered in a plugin?
- Keeping and updating ACF and ACF Pro at the same time
- Pass user role to javascript code inside body
- A plugin that downloads other plugins
- Php page with filters for custom fields
- How to be escape Variables and options when echo?
- (WordPress 5.8.3) Function.php or a plugin for better performance? [duplicate]
- Basic question about accessing scripts in my plugin
- Gutenberg Blocks – Cannot retrieve block saved attributes in edit post
- plugins not working in custom theme
- How to use template_include hook with form submission?
- Adding Plugin Assets to Header
- Release the plugin in the WordPress repository where redux is used
- How to Define Multiple List Tables in a Single Submenu
- Add item to the woocommerce dashboard menu from a plugin
- Can the uniqueness of the plugin file/plugin slug and version number be trusted?
- Add type to enqueued script inside plugin
- Dokan Marketplace store link in single product page
- How can I redirect some pages to new subdomain? [closed]
- Automatically download, install and activate plugins that my plugin depends, how?
- Integrating boxtal PHP library into a custom WordPress Plugin
- wp-mail attachment is not sent for no reason?
- Translations for my plugin don’t show up
- Changing menu order of a specific plugin in dashboard
- Error in pdf generating plugin using FPDF
- syntax error, unexpected ‘while’ (t_while) please help :)
- How to create WordPress custom end point with multiple parameters?
- Plugin has added weird data in wp_options, set to autoload
- Different custom templates for product category [closed]
- Text change in Advanced Customs Fields [closed]
- How to remove bulk actions from custom post type
- After updating the WordPress getting a syntax error in the console
- Images under 1MB are not being compressed
- How to check wp_options’s rewrite_rules if current and existing are the same before flush the rules?
- What is the easiest way to rename a plugin (and also avoid plugin updates)
- Setting Email locale before retrieving gettext translations
- Changes not visible when not logged in
- Display linked articles at the bottom of post (like related posts)
- Simulating a wp page – wp page load sequence
- register_activation_hook() not working as expected
- How to redirect to same page after form submission
- Any idea how to get something like this to work? [closed]
- WordPress Ajax code is not Working
- Is there a maximum length to a WordPress Page?
- Skewed / slanted button within elementor [closed]