XPro Theme Builder Shortcodes

Below, you’ll find a detailed guide on how to add the Best Theme Builder For Elementor – FREE Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Best Theme Builder For Elementor – FREE Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Best Theme Builder For Elementor – FREE Plugin and the shortcodes it provides:

Plugin Icon
Best Theme Builder For Elementor – FREE

"Best Theme Builder For Elementor – FREE is a user-friendly plugin for WordPress. It lets you design and customize appealing themes using Elementor. With the xpro-theme-builder slug, it's free to use."

★★★★★ (10) Active Installs: 3000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [xpro_theme_builder_template]
  • [xpro_comments_template]

Best Theme Builder For Elementor – FREE [xpro_theme_builder_template] Shortcode

The xpro-theme-builder plugin shortcode is designed to render a specific template based on its ID. It uses the ‘xpro_theme_builder_template’ shortcode to achieve this. The shortcode takes ‘id’ as an attribute, which represents the template’s ID. If no ID is provided or if the ID is invalid, it returns an empty string. It also checks for Elementor’s presence and enqueues the necessary CSS file for the template. If Elementor is active, it uses Elementor’s frontend class to display the content of the template.

Shortcode: [xpro_theme_builder_template]

Parameters

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

  • id – The unique numeric identifier for the template.

Examples and Usage

Basic example – Showcases a simple usage of the shortcode to render a template using its ID.

[xpro_theme_builder_template id=123 /]

For more complex scenarios, the shortcode can be used with additional attributes. However, based on the given code, the shortcode only accepts the ‘id’ parameter. Therefore, an advanced example would involve the use of the shortcode within PHP code or within another shortcode that accepts parameters.

PHP Function Code

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

Shortcode line:

add_shortcode( 'xpro_theme_builder_template', array( $this, 'render_template' ) );

Shortcode PHP function:

                    function render_template( $atts ) {

		$atts = shortcode_atts(
			array(
				'id' => '',
			),
			$atts,
			'xpro_theme_builder_template'
		);

		$id = ! empty( $atts['id'] ) ? apply_filters( 'xpro_theme_builder_render_template_id', intval( $atts['id'] ) ) : '';

		if ( empty( $id ) ) {
			return '';
		}

		if ( self::$elementor_instance ) {
			if ( class_exists( '\Elementor\Core\Files\CSS\Post' ) ) {
				$css_file = new Post( $id );
			} elseif ( class_exists( '\Elementor\Post_CSS_File' ) ) {
				// Load elementor styles.
				$css_file = new Post_CSS_File( $id );
			}
			$css_file->enqueue();
		}

		if ( self::$elementor_instance ) {
			return self::$elementor_instance->frontend->get_builder_content_for_display( $id );
		}

	}
                    

Code file location:

xpro-theme-builder/xpro-theme-builder/plugin.php

Best Theme Builder For Elementor – FREE [xpro_comments_template] Shortcode

The Xpro-theme-builder shortcode enables the display of comments on your WordPress site. It checks if comments are open or if there are existing comments, then calls the comments template.

Shortcode: [xpro_comments_template]

Examples and Usage

Basic example – The Xpro theme builder plugin provides a shortcode to display the comments template on a page or post. This basic example shows how to use the shortcode without any additional parameters.

[xpro_comments_template /]

Advanced examples

Currently, the ‘xpro_comments_template’ shortcode doesn’t support any additional parameters. The function tied to this shortcode is designed to check if comments are open or if there are any comments for the post, and then display the comments template. However, if you want to extend the functionality of this shortcode, you could modify the related PHP function to accept additional parameters. For instance, you could add a ‘post_id’ parameter to display the comments template for a specific post.

Example: Add ‘post_id’ parameter to ‘xpro_comments_template’ function.


function xpro_theme_builder_comments_template($atts) {
    $atts = shortcode_atts(
        array(
            'post_id' => get_the_ID(), // default value
        ), 
        $atts, 
        'xpro_comments_template'
    );

    $post_id = $atts['post_id'];

    if ( ( comments_open($post_id) || get_comments_number($post_id) ) ) {
        comments_template('', true);
    }
}
add_shortcode( 'xpro_comments_template', 'xpro_theme_builder_comments_template' );

With the modified function, you can now use the ‘xpro_comments_template’ shortcode to display the comments template for a specific post by passing the ‘post_id’ parameter.

[xpro_comments_template post_id=123 /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'xpro_comments_template', array( $this, 'xpro_theme_builder_comments_template' ) );

Shortcode PHP function:

                    function xpro_theme_builder_comments_template() {
		if ( ( comments_open() || get_comments_number() ) ) {
			comments_template();
		}
	}
                    

Code file location:

xpro-theme-builder/xpro-theme-builder/plugin.php

Conclusion

Now that you’ve learned how to embed the Best Theme Builder For Elementor – FREE Plugin shortcodes, 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 *