Yes, shortcode attributes are always strings. WordPress has no way of knowing the intended type of each attribute, and the values are ultimately pulled from an HTML string, after all.
If you need $id
to be an integer, just do this:
$args = ( shortcode_atts( array('id' => ''), $atts ) );
$id = (int) $args['id'];
if ( ! $id ) {
return;
}
$content = get_reusable_block( $id );
Related Posts:
- Using get_option() in JavaScript
- Shortcode empty attribute
- Using wp_editor in shortcode
- Why are you using add_action for shortcode?
- How to get URL param to shortcode?
- How can I put a wp_redirect into a shortcode?
- How to display the names of users from a specific group with a shortcode?
- shortcode for logo image
- Using audio shortcode for .mp3 URLs with a query string
- Get multiple shortcode attribute values
- Why do_shortcode is not executing the shortcode in data-* html attributes?
- How to display some selected user meta data on a specific page with a shortcode?
- Gallery shortcode menu order fix no longer working on WordPress 4.0
- has_shortcode for content added after the content
- Shortcode displays only default attribute values
- Can a shortcode function this way
- Creating a Slider Shortcode Based on Nivo Slider
- Passing attributes to shortcode dynamically
- Stop parsing shortcodes
- WordPress auto adds p to shortcode parameters
- Why isn’t this youtube shortcode working?
- Gist shortcode is not working
- ShortCode and extra
- How to change page title (from a plugin) in twentytwentyone theme
- WordPress Code Standards and Working $link Parameters In Shortcode
- How to set Contact Form 7 fields default value using shortcode attribute? [closed]
- Display post metadata: “title, category, author, date” with shortcode
- shortcode javascript not working on custom template file inside theme folder
- Check if post has gallery images/media
- Stop auto formatting in shortcodes
- If you add a shortcode programmatically, but the code isn’t viewed on that request, is it still executed?
- Get URL Param Plugin and Inserting Result in Widget Code
- Add shortcode support to custom field
- Preserve shortcode content formatting
- Shortcode help: If no image entered take default
- How can I escape a section of my page which contains multiple shortcodes?
- shortcode to display post by category entered by user without plugin
- Reloading a Mediaelement audio player
- Adding Shortcode Values to wp_head
- How to change the output of gallery shortcode
- wp_list_pages shortcode jumps above previous content
- Shortcode attributes don’t appear?
- Shortcodes: closing shortcode not being processed
- Retrieving post excerpt as a shortcode
- Insert PHP code via shortcode?
- Div-Wrap with Functions.php in Childtheme using Shortcode!
- Trying to call dynamic content as a shortcode attribute
- What is the correct syntax to append a URL using a shortcode for an iframe?
- Shortcodes in RSS excerpts
- shortcode issue in the_excerpt
- A shortcode nested inside a shortcode
- How to add shortcode to html widget
- Implementing a URL Shortener
- Custom Shortcode + Querying and Ordering Posts using multiple Advanced Custom checkboxes
- Add div on EMED Tag
- Clean way of using ob_start() and ob_end_clean() in wordpress
- Theme Convert PHP code to shortcode
- call other shortcode in the email contactform7 send [closed]
- find shortcode inside content of post
- WordPress Short code for List style
- Putting a space between the buttons [closed]
- Processing a login/register form before shortcodes are rendered?
- Adding a cover image to video shortcode
- Insert First Image into post (full-width)
- Dynamic number within shortcode
- Show content if user left comment / non-logged visitors?
- How to insert current user ID/entry ID into a shortcode?
- WP REST API remove the WordPress shortcodes from the JSON wp/v2/posts content->rendered
- How to display html element and php string in the same line?
- Using a WP shortcode in Homepage
- i want to show a modal when user lands on home page very first time
- WordPress Shorcode Display hierarchical taxonomy [child, parent]
- Shortcode not working in Jetpack Top Posts & Pages widget
- Restricting shortcode for users
- Shortcode, vs blocks, vs templates – what would you do for choosing or creating custom post data in editor?
- create shortcode that changes url endpoint
- Logout user if click on a custom page link
- Convert WordPress shortcodes into plain html
- Attributes are not passed on nested shortcode
- How to make a shortcode with a line break in it parse correctly?
- Removing text + shortcode from all posts
- Is Post-Author-Id shortocde
- Load next post by ID on a single page
- Add catagory attribute to custom shortcode
- Access the resized images generated by `add_image_size()`
- Class variables in shortcodes
- Defining the output of a WordPress Att
- Remove width and height attributes from [gallery] output
- Custom WP theme not showing shortcodes
- Shortcode for sectors
- How to not show shortcode contents if cart is empty?
- A number appears inside a div called wpb_wrapper, when I use a custom shortcode
- Enclose article’s body with default shortcode
- Shortcode with foreach
- Hook into existing shortcodes to manipulate the attributes?
- How can I hide the ACF shortcode when empty
- How to pass text input data to shortcode
- Using variable as shortcode parameter
- How to handle Ajax Calls, when using same shortcodes (with different parameters, e.g. ‘post-type’)?
- conditional shortcodes