While annoying, your plugin is functioning properly. The page completely renders itself first, showing the sidebar, and then the JavaScript code activates to hide the sidebar.
The fix for this is to have your PHP code check/grab the user’s cookie and set the display’s sidebar status accordingly. That way when the page renders it will be set to none initially, and then any future image toggles can hide/show the sidebar dynamically.
When the page is loaded again for whatever reason, the same PHP loading code will run again, and set the initial state of the sidebar accordingly, without any need to “follow up” after the initial page load to show/hide the sidebar.
Hopefully this makes sense. If you need some specifics, you might try updating your question with the code involved.
Related Posts:
- How do I “unhook” / de-register jQuery so that it’s not called as part of wp_footer();?
- Returning Variables back into a template
- Can not Remove Archives and Meta from Sidebar
- Unhook jQuery from WooCommerce via `functions.php`? [closed]
- Custom theme, contact form 7 & fast secure form doesn’t work
- Load sidebar template just once to prevent multiple animations
- Replace single_template filter with what for default posts?
- JQuery undefined and Stylesheet loads in bottom along with js files
- Load different single.php templates according to post layout selection
- Enable WP to accept standard jQuery code embeding between the tags [duplicate]
- enqueue script if page is not equal to
- Custom single template for a specific category
- What is the difference between wp_register_sidebar_widget and register_widget?
- How does WordPress decide what template to use as frontpage
- How can I get wp_head() as a string instead of echoing it?
- Why does my short code get executed before other content?
- How can I see what template parts are being called for rendering the viewable page?
- How to change post thumbnail title and alt attributes to post title?
- Why might $input (Settings API) be coming through empty?
- How to get the name and description of a sidebar in theme?
- Best approach for loading a sidebar Only if the screen max-width is >900px?
- How to Handle CSS for Multiple Header header.php Files?
- Merging PHP download script into `functions.php`
- Static Front Page problem
- Is there an error in get_the_tag_list()?
- WordPress Google Maps in Custom Theme
- How to override BuddyPress 3.0 bp-nouveau theme files?
- Allow users to add custom functions to wordpress theme
- How to add custom template tag in wordpress theme?
- How do I display the “Archives” widget layout (sidebar) in WordPress by ‘year’ then by ‘months’?
- Setting hero/splash section as a blog post
- Where is the correct place(s) in twentysixteen’s header.php to add a Google webfont?
- Getting jquery to work with custom theme
- How to retrieve an image from a post and display it before excerpt of a post? [duplicate]
- Add external js file to footer with id
- Make “sidebar template” the default template for new pages
- Adding wp_enqueue_media(); causes problem
- New template, where to place CSS?
- Is there a theme function for is_password_protected()?
- get_query_var() and permalinks
- Move theme templates to subfolder without losing page associations
- How to store functions in… functions.php?
- Why are theme templates organized as multiple point of entry PHP files instead of reusing your theme’s index.php?
- is_dynamic_sidebar always returns true while using Jetpack visibility
- Check if home.php and set home.php as page_on_front
- jQuery not available to other scripts
- Override template file i subfolders
- Single Page theme [closed]
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- Should I use add_filter for functions in function.php of the theme?
- Do i need to keep all the default WP templates files in a theme?
- how to display search term in the template full site editor
- How to override p2 breathe theme plugin in content template file?
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- “Theme without sidebar.php is deprecated”
- Using page-id-{ID} from body_class() in local dev, versus live staging
- Template for landing pages
- Unique design inside a specific category’s url
- How to call multiple functions from multiple files into a WordPress page template [closed]
- How to make javascript work on theme options page
- How can I hard code my sidebar?
- How to call the_time current?
- Should is_active_sidebar() always be used around dynamic_sidebar()?
- Shortcode call not working in WP Template
- A post with a clear:both in its css destroy the theme design, and the sidebar is moved to the bottom
- How to add sidebar to Isola theme? [closed]
- Create theme for mobile phones and tablets only?
- Change the sidebar from left to right twentyfourteen theme
- How to create a WP theme that use BootStrap? [closed]
- Changing sidebar.php and footer.php depending on URL
- Recommended sidebar / content widths
- loading javascript after jquery is loaded
- MapPress Easy Google Map in Jquery Tabs Problem
- How to setup sidebar modules to use jQuery Accordian
- How to Modify WP_Includes/blocks/latest_posts.php
- Sidebar not displaying (theme development)
- How to implement pagination in category.php template
- Embedding CodePen Calorie Script – jquery error
- Infinite scroll without plugin using ajax
- change background image on scroll
- Cold Fusion to WordPress
- Using wp_add_inline_style Inside a Template File
- Undefined index: custom_sidebars
- jQuery conflict in WordPress, works fine in HTML
- FitVid not working for iframes on particular theme install
- Creating a Playlist of Widgets
- How to display only some widgets of a sidebar?
- Problem with multiple menus in theme
- How to Remove Sidebar when get_sidebar() is not get called in page?
- WordPress two sidebar layout or theme
- apply_filters to featured image
- Mamp pro permalink issues. Pages keep reverting to index.php
- WordPress Subpages Fancybox Trouble
- Add the title of a widget as an ID – for anchor links
- Incorrect sidebar showing on WooCommerce Store page [closed]
- can’t add EVENT LISTENER to a element
- Getting URL of Resized Image
- Adding a new layout for genesis
- Meaning of “if ( is_home() && ! is_front_page() )” snippet?
- What is the point of using archive.php instead of index.php?