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
- Best practices regarding the creation of custom widgets?
- Sort wp_query by sum of two meta fields
- How to override p2 breathe theme plugin in content template file?
- How to: JQuery multiple wordpress media uploader buttons in the same options page?
- Move default page templates to sub directory
- Jquery implementation not working on page reload
- What can I use for small text when converting to WordPress?
- Displaying details of a post in a sidebar
- How to disable controls in theme customizer?
- Theme Customizer not loading JS for live preview
- Post thumbnail to append post content via ajax click event
- Remove “You are using WordPress 3.2.1” from Right Now Dashboard Widget
- Would to use AJAX to get an option from the database and use it in a jquery setup or is there an alternative to consider?
- Is the “_s” on this `sprintf(__(‘Page %s’, ‘_s’), max($paged, $page))` just refer to a text domain?
- “Theme without sidebar.php is deprecated”
- Replace function in a child theme
- Where to place template files?
- Using page-id-{ID} from body_class() in local dev, versus live staging
- My jQuery is enqueued properly. So why isn’t it working?
- Is there any tool to find lines of codes responsible to generate front-end HTML elements?
- How do I get the trackback count of a post in wordpress without writing an SQL query?
- Use WordPress function in php file
- Change the “Default Avatar” admin option via functions.php
- Need help with adding templates (archives and sitemap) to WordPress child theme
- 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 seperate static phrases from template files in custom theme?
- Javascipt issue on custom theme
- Define PHP variable from a seperate API if statement
- How to make javascript work on theme options page
- How is the `get_sidebar` function meant to be used to call a 2nd sidebar?
- Broken theme, template is missing
- Should I create multiple sidebars, or use or one dynamic sidebar with logic to determine it’s abilities?
- Theme not calling Jquery properly
- How to add menù section to my WordPress template?
- Weirdness in jQuery supplied with WordPress
- How can I hard code my sidebar?
- Run a jquery script on on a certain template page
- How to call the_time current?
- Post and page content not displaying in search results
- Why still output /wp-content/themes/twentynineteen?
- Should is_active_sidebar() always be used around dynamic_sidebar()?
- jQuery from parent theme loaded with many other scripts in a single min.js file
- How to add custom meta box when you have a custom page template file
- Password protect a custom template
- Templates dropdown not appearing using _s theme (underscores)
- 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?
- Confused by the behaviour of “front page” / “home” templates
- Trouble in enquing all js files under certain directory
- I need to develop a one-page design
- Allow different tags in widget titles
- Change the sidebar from left to right twentyfourteen theme
- add jquery file if a certain page is included
- Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]
- How to create a WP theme that use BootStrap? [closed]
- Changing sidebar.php and footer.php depending on URL
- Add content after get_header
- Can’t change theme name
- How to set default values for edit_post_link() in my theme?
- How do I implement jPanelMenu?
- How to link to the page displayed by home.php?
- Under theme folder, what’s sequence of action for index.php, page.php, single.php?
- Recommended sidebar / content widths
- How to make excerpt image be full size instead of thumbnail?
- loading javascript after jquery is loaded
- MapPress Easy Google Map in Jquery Tabs Problem
- Is there a template tag I can use to link to the archive page corresponding to the month that a post was published on?
- Hide/disable sidebar using shortcode?
- How to setup sidebar modules to use jQuery Accordian
- I don’t think WordPress is loading jquery or bootstrap js
- How to Modify WP_Includes/blocks/latest_posts.php
- how can i remove js file from my footer in wordpress
- How to properly use AWS SES for a contact form?
- Sidebar not displaying (theme development)
- How to implement pagination in category.php template
- Embedding CodePen Calorie Script – jquery error
- How to load jQuery with Ajax in WP version 5.3.2?
- How to enqueue scripts properly with ES6 webpack?
- Infinite scroll without plugin using ajax
- change background image on scroll
- Cold Fusion to WordPress
- Template for front page (latest posts)
- Using wp_add_inline_style Inside a Template File
- which template should I use for single category post?
- Should I use template files or just use conditional tags in index.php?