Is easy to use 0
and 1
values and then typecasting inside the function:
[shortcode boolean_attribute="1"]
or [shortcode boolean_attribute="0"]
but if you want you can also strictly check for 'false'
and assign it to boolean, in this way you can also use:
[shortcode boolean_attribute="false"]
or [shortcode boolean_attribute="true"]
Then:
add_shortcode( 'shortcode', 'shortcode_cb' );
function shortcode_cb( $atts ) {
extract( shortcode_atts( array(
'boolean_attribute' => 1
), $atts ) );
if ( $boolean_attribute === 'false' ) $boolean_attribute = false; // just to be sure...
$boolean_attribute = (bool) $boolean_attribute;
}
Related Posts:
- Conditionally Loading JavaScript/CSS for Shortcodes
- Escaping quotes from shortcode attributes
- How to add ‘class’ attribute into shortcode [audio]?
- Automatically add this attribute to the gallery shortcode
- How to handle valueless attributes in shortcodes?
- Get multiple shortcode attribute values
- wpautop() when shortcode attributes are on new lines break args array
- Remove width and height attributes from [gallery] output
- Add attribute to existing Shortcode
- Shortcode displays only default attribute values
- Extending Shortcode attributes
- Remove HTML content if attribute is not set / variable attributes
- Global, network-wide shortcodes or text replace functions
- getting values from a shortcode with an include
- Why are Shortcodes Disabled in Widgets by Default?
- Add attribute to shortcode dynamically
- Replace / Remove Shortcode after 1st run / post
- Caption shortcodes not including caption as attribute
- Conditionally Loading JavaScript/CSS for Shortcodes
- Check if CTP category taxonomy is set in shortcode
- Passing variable in nested shortcodes
- How to use a nested shortcode to render the value of an attribute in parent shortcode
- Which wordpress function is the caption shortcode linked to?
- How to process a single attribute in a SQL request twice times?
- shortcode atts not working
- Second attribute of shortcode is not changing why?
- Replace custom gallery shortcode with default gallery shortcode
- Shortcode Attribute contains clone of all shortcode attributes
- How can I define the output of shortcode attribute value?
- Remove width and height attributes from [gallery] output
- Optimize shortcode callbacks
- Create custom [sourcecode] shortcode, the right way?
- TED talks shortcode not working
- What is the best way to enable nested shortcodes?
- Set wmode attribute to transparent for the embed shortcode to make drop-down menu hover over YouTube embed in Internet Explorer
- how do you get the author’s username?
- do_shortcode inside AJAX callback
- shortcode_unautop shortcode not functioning
- How can I run shortcode after click with ajax
- Execute shortcode within shortcode
- How to create a shortcode to display a category description?
- shortcode not working and the relation to the_content()
- Shortcode But Without The Equals Sign?
- shortcodes between square and curly brackets
- Font Awesome Icons Won’t Work
- How to Get a part of URL and put in shortcode?
- Is there any inherent difference between add_filter() and add_shortcode() for modifying [caption]?
- get_shortcode_regex() only matches first shortcode
- Looking for a way to include/embed text from a file on a page so that the short codes are processed
- How do I debug a short code?
- How to type shortcode-like text in WordPress TinyMCE visual editor?
- Does registering multiple shortcodes impact performance?
- How can I hide the Permalink/Shortlink for certain user logged in Users of a certain level?
- How to force that styles are enqueued in the header?
- add action only if gallery shortcode attribute is equal to?
- How To Conditionally Include A Short Code Depending On The HTTP_REFERER [closed]
- Shortcode for order number [closed]
- Create shortcode in WordPress, using one variable in 3 functions?
- Adding javascript actions to words in post content
- My shortcode does not call the function
- Hide Selection of Text From Archive, but Show on Single Posts
- How to create an incremental list using shortcodes?
- How to Generate html tags using shortcodes?
- Do shortcode that is inserted in a textarea is not displaying properly
- Adding custom form within add_shortcode
- wp_editor not rendering the shortcode
- how to add shortcode in wordpress container [duplicate]
- How to make this shortcode work for post content wordpress [duplicate]
- stop WordPress removing shortcode from content [closed]
- Is it possible to handle two or more shortcodes in a single page?
- Toggle Shortcode Sanitize Title
- Clearfix Shortcode
- How and when to include shortcode source files
- Use full size images in a specific gallery
- how to create a fav icon shortcode?
- How to deal with WordPress bug: can’t use wrapped and unwrapped shortcode on same post
- Execute Shortcodes when submitting post
- Substituting value via shortcode
- Create shortcode for each form field in contact form 7
- Auto embeds don’t work for attachment descriptions
- Shortcode to appear and show the date not code in Title and description of Social Media sites
- how to add shortcode widget at end of main blog page
- Shortcode is not showing content when placed in editor (post_type = page)
- How to set up posts per page on WP
- How to insert a short code into Contact Form 7 in WordPress that will call a function once the submit button is pressed
- Unable to make shortcode, what is wrong?
- How do i remove Business feeds Shortcode fatal error
- Push Shortcode parameter to template
- latest posts shortcode with image
- WordPress Gallery with ID’s Shortcode not Working
- Featured image with link to post shortcode, image displaying above the post
- Video shortcode inside tabs shorcode NOT working
- How to stop unwanted splits in excerpts when using shortcodes for sliders or players
- How to add meta slider lite or other slider to main page header in pinboard theme
- Escaping a shortcode so it displays as-is [duplicate]
- WordPress do_shortcode first iteration
- Add a short code to a plugin
- Applying if (get_post_meta) to new shortcode
- Add widget/shortcode to sidebar OUTSIDE of the theme
- Why does my shortcode query not working with search term