B Slider Shortcode

Below, you’ll find a detailed guide on how to add the B Slider Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the B Slider – Slider for your block editor Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the B Slider – Slider for your block editor Plugin and the shortcodes it provides:

Plugin Icon
B Slider – Slider for your block editor

"B Slider – Slider for your block editor is a WordPress plugin that enhances your website's visual aesthetics. With B Slider, effortlessly create and manage dynamic slideshows directly from your block editor."

★★★★✩ (7) Active Installs: 5000+ Tested with: 6.3.2 PHP Version: 7.1
Included Shortcodes:
  • [bsb-slider]

B Slider [bsb-slider] Shortcode

The B-Slider shortcode is a powerful tool for displaying specific posts in a slider format. This shortcode retrieves a post using its ID, parses the content into blocks, and renders the first block. It’s a streamlined way to showcase specific content on your WordPress site.

Shortcode: [bsb-slider]

Parameters

Here is a list of all possible bsb-slider shortcode parameters and attributes:

  • id – Unique identifier of the post to display

Examples and Usage

Basic example – A simple shortcode usage to display the bsb-slider by referencing the post ID.

[bsb-slider id=1 /]

Advanced examples

Using the shortcode to display multiple bsb-sliders by referencing their IDs. This example will display the sliders with the ID 1, 2, and 3.

[bsb-slider id="1,2,3" /]

Using the shortcode to display a bsb-slider by referencing the post ID and adding additional parameters. This example will display the slider with the ID 1 and it will auto play with a speed of 5000 milliseconds (5 seconds).

[bsb-slider id=1 autoplay=true speed=5000 /]

Please note that the additional parameters like autoplay and speed may or may not work based on the actual implementation of the bsb-slider plugin.

PHP Function Code

In case you have difficulties debugging what causing issues with [bsb-slider] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'bsb-slider', [$this, 'onAddShortcode'], 20 );

Shortcode PHP function:

function onAddShortcode( $atts ) {
		$post_id = $atts['id'];
		$post = get_post( $post_id );

		$blocks = parse_blocks( $post->post_content );

		return render_block( $blocks[0] );
	}

Code file location:

b-slider/b-slider/custom-post.php

Conclusion

Now that you’ve learned how to embed the B Slider – Slider for your block editor Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *