Below, you’ll find a detailed guide on how to add the Piotnet Addons For Elementor 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 Piotnet Addons For Elementor Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Piotnet Addons For Elementor Plugin and the shortcodes it provides:
"Piotnet Addons for Elementor is a powerful WordPress plugin that enhances the capabilities of the Elementor page builder. It offers advanced widgets and features for unique page design."
- [pafe-template]
Piotnet Addons For Elementor [pafe-template] Shortcode
The Piotnet Addons for Elementor shortcode ‘pafe-template’ enables the display of Elementor templates. It checks if Elementor is active and if the template ID is set. . If both conditions are met, it fetches and returns the specified template content for display. If not, an empty string is returned, ensuring no errors occur.
Shortcode: [pafe-template]
Parameters
Here is a list of all possible pafe-template shortcode parameters and attributes:
id
– The unique identifier of the Elementor template
Examples and Usage
Basic example – The shortcode displays the Elementor template with the specified ID.
[pafe-template id=2 /]
Advanced examples
The shortcode can be used to display different Elementor templates based on conditional logic. For instance, you could display different templates for different user roles or based on the current page.
Here’s an example of how you might use the shortcode to display a different Elementor template for logged in users and guests:
if(is_user_logged_in()){
echo do_shortcode('[pafe-template id=3 /]');
} else {
echo do_shortcode('[pafe-template id=4 /]');
}
And here’s an example of how you might use the shortcode to display a different Elementor template based on the current page:
if(is_front_page()){
echo do_shortcode('[pafe-template id=5 /]');
} elseif (is_single()) {
echo do_shortcode('[pafe-template id=6 /]');
} else {
echo do_shortcode('[pafe-template id=7 /]');
}
PHP Function Code
In case you have difficulties debugging what causing issues with [pafe-template]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('pafe-template', [ $this, 'pafe_template_elementor' ] );
Shortcode PHP function:
function pafe_template_elementor($atts){
if(!class_exists('Elementor\Plugin')){
return '';
}
if(!isset($atts['id']) || empty($atts['id'])){
return '';
}
$post_id = $atts['id'];
$response = \Elementor\Plugin::instance()->frontend->get_builder_content_for_display($post_id);
return $response;
}
Code file location:
piotnet-addons-for-elementor/piotnet-addons-for-elementor/piotnet-addons-for-elementor.php
Conclusion
Now that you’ve learned how to embed the Piotnet Addons For Elementor 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.
Leave a Reply