Content Slider Block Shortcode

Below, you’ll find a detailed guide on how to add the Content Slider Block 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 Content Slider Block Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Content Slider Block Plugin and the shortcodes it provides:

Plugin Icon
Content Slider Block – Display slider in a beautiful way.

"Content Slider Block is a WordPress plugin designed to display your slider content in a stunning, visually appealing manner. Enhance your site's aesthetics with this easy-to-use tool."

★★★✩✩ (4) Active Installs: 3000+ Tested with: 6.3.2 PHP Version: 7.1
Included Shortcodes:
  • [csb]

Content Slider Block [csb] Shortcode

The Content Slider Block (CSB) shortcode is a tool that retrieves and displays a specific WordPress post. The shortcode uses the ‘id’ attribute to identify the post. It then extracts the post content and parses it into blocks. The first block is then rendered and returned, effectively displaying the content of the specified post.

Shortcode: [csb]

Parameters

Here is a list of all possible csb shortcode parameters and attributes:

  • id – It’s the unique identifier for the specific post.

Examples and Usage

Basic example – In this example, we are using the ‘csb’ shortcode to display a specific post by referencing its ID.

[csb id=3 /]

Advanced examples

Here we are using the ‘csb’ shortcode to display multiple posts by referencing their IDs. The posts will be displayed in the order of the IDs listed.

[csb id="3,6,9" /]

In this next advanced example, we are using the ‘csb’ shortcode to display a specific post by referencing its ID and specifying additional parameters. The ‘size’ parameter adjusts the display size of the post, and the ‘align’ parameter adjusts the alignment of the post on the page.

[csb id=3 size="large" align="center" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'csb', [$this, 'onAddShortcode'] );

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:

content-slider-block/content-slider-block/inc/custom-post.php

Conclusion

Now that you’ve learned how to embed the Content Slider Block 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 *