You’ve seen these before. An Info Bar is used for time-based notices like sales, expiring coupons, changes of physical store hours.
GeneratePress Premium makes it easy to add these to your site, either site-wide or targeted to specific pages, specific posts, specific products, tag groups, categories, logged-in users, logged-out users… you get the idea.
Method 1 – Using GP Elements
Required: GeneratePress Premium (GPP) for the Elements module. (Ensure GPP’s Elements module is activated.)
- Create a new GPP Element, Block type. Style for its purpose.
- Set the Element type to “Hook”, and Hook name to
before_header
. - Set your Display Rules. In this example, we want the Info Bar to appear across the entire site.
Method 2 – Using Reusable Blocks (recommended for management by end-users)
- For this method, create your block as a Reusable Block. In most WordPress installations, you can find this hidden admin area by going to Pages and then changing the
?post_type=page
part of your address bar to?post_type=wp_block
- After creating your Info Bar content and saving it, take note of its post ID. This is also in its address bar. For example, in /wp-admin/post.php?post=319&action=edit, the post ID of my reusable block is 319.
Next, we need to create the controls for this so the client can manage it. Pick a page to place them on (or place this control on your Site Options page), and let’s create a custom field for it using Advanced Custom Fields (ACF).