Some time back we shared a small snipped that would create a show or hide a content blind in WordPress. Unfortunately, it sucked. I still remember writing the code as a quick solution to a client request bouncing around in the back of car during a layover in Los Angeles... and this was in the days when all I had was my trusty Nokia E72. The code on this page isn't necessarily much better but it does negate the need for scoped CSS, and with the exception of a scrolling delay that 'animates' the content blind it's not entirely different to the original. I'm sharing this code here rather than our Codex only because it was necessary for an article published a few days ago, and it replaces the shonky previous version.
A feature not totally unlike what is shown below is included in our client plugin as a calendar display option; in many cases a client won't want to render a standalone calendar on a page (which is a one-click feature provided by default) in Yabber , but showing a calendar by way of 'Make a Booking' text may be useful.
The result is rather pedestrian, but still very nice on the page.
Yep, you've clicked me and now you're seeing hidden text. You may alter the link text and the speed at which the blind renders. Simple. As we said, it's handy for elements such as a calendar (integrated into Yabber by default) but it's also useful for notes, comments, and less relevant content blocks.
While editing CSS inline upsets many, there's an option for cases when you want to include styling to the returned DIV; in this case we've also provided an unrealistic toggle delay of 2 seconds. For example.
This is content with a margin to the left... not unlike our default note
shortcode. A silly two-second delay was applied.
Shortcode Usage
To return a basic blind, and not unlike our previous shortcode, simply use as follows: [blind title="Title in here"]Your Content in here...[/blind]
.
WordPress Shortcode
Copy and paste the WordPress function into your theme's functions.php
file or, if you sensibly have one installed, your custom functions plugin.
If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.
Shortcode Attributes
The following shortcode attributes are available.
text
delay
delay="2000"
.show
show="1"
.style
style="border-left: 1px solid #000000; padding-left: 30px;"
.Considerations
The code isn't ideal, but it's short and easy to use. If you're a client and logged into our client portal you'll have access to a standalone Elementor block. However, the feature is now included in our BeliefMedia plugin by default.
Download
Title: Show Content in WordPress in a Rolling Blind with Shortcode
Description: Clicking on a text link will show or hide a block of text on your WordPress page. Various options apply.
Download • Version 0.1, 861.0B, zip, Category: WordPress Shortcodes