Friday 6 October 2017

Add a site-wide dismissible notice bar to your WordPress website


Global, site-wide website notices are a pattern as old as websites themselves, and although they are being abused all the time they do have valid use-cases and are extremely useful in situations where we absolutely need to notify our visitors of something important, e.g. a great deal (as we do here at CSSIgniter), any kind of maintenance message or even the EU cookie law notice! When the need rises for such functionality the first thing on anyone’s mind would probably be to have a look at the WordPress plugin repo for any suitable plugins, and, well, although it’s justified (there are a ton of plugins for this kind of thing) there’s no reason not to implement it ourselves since it’s so easy and fun.
Without any further ado, then, let’s see how we’d go about building a simple, global, dismissible site-wide notice bar.
Our basic architecture
We’ll store our notice’s text as a simple WordPress Customizer setting, and then we’ll use some JavaScript tinkering to handle its display logic. Of course, we’ll also use some basic CSS to style it.
The customizer setting
All we need for our notice currently is a single text field. Ever
Source: https://managewp.org/articles/16264/add-a-site-wide-dismissible-notice-bar-to-your-wordpress-website




source https://williechiu40.wordpress.com/2017/10/06/add-a-site-wide-dismissible-notice-bar-to-your-wordpress-website/

No comments:

Post a Comment