Royal Elementor Addons and Templates Shortcode

Below, you’ll find a detailed guide on how to add the Royal Elementor Addons and Templates 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 Royal Elementor Addons and Templates Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Royal Elementor Addons and Templates Plugin and the shortcodes it provides:

Plugin Icon
Royal Elementor Addons and Templates

"Royal Elementor Addons and Templates is a dynamic WordPress plugin that enhances your website's functionality by providing advanced design elements and ready-to-use templates. Boost your site's appeal now!"

★★★★☆ (289) Active Installs: 200000+ Tested with: 6.3.2 PHP Version: 5.6
Included Shortcodes:
  • [wpr-template]

Royal Elementor Addons and Templates [wpr-template] Shortcode

The Royal Elementor Addons plugin shortcode, ‘wpr-template’, is designed to display a specific template content on the frontend. This shortcode requires an ‘id’ attribute which corresponds to the template ID. If the ID is not specified, it returns an empty string. It also provides an ‘Edit Template’ button to directly edit the template. The shortcode checks if the template has CSS and displays the template content accordingly.

Shortcode: [wpr-template]

Parameters

Here is a list of all possible wpr-template shortcode parameters and attributes:

  • id – Unique identifier for the template to display.

Examples and Usage

Basic example – A simple usage of the shortcode to display a specific template by referencing its ID.

[wpr-template id=3 /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'wpr-template', [ $this, 'shortcode' ] );

Shortcode PHP function:

function shortcode( $attributes = [] ) {
		if ( empty( $attributes['id'] ) ) {
			return '';
		}

		$edit_link = '<span class="wpr-template-edit-btn" data-permalink="'. esc_url(get_permalink($attributes['id'])) .'">Edit Template</span>';
		
		$type = get_post_meta(get_the_ID(), '_wpr_template_type', true);
		$has_css = 'internal' === get_option( 'elementor_css_print_method' ) || '' !== $type;

		return Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $attributes['id'], $has_css ) . $edit_link;
	}

Code file location:

royal-elementor-addons/royal-elementor-addons/admin/includes/wpr-templates-shortcode.php

Conclusion

Now that you’ve learned how to embed the Royal Elementor Addons and Templates 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 *