Cowidgets – Elementor Addons Shortcodes

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

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

Plugin Icon
Cowidgets – Elementor Addons

"Cowidgets – Elementor Addons is a powerful WordPress plugin that enhances your Elementor page builder with unique, creative widgets to boost your website's functionality and design."

★★★★★ (2) Active Installs: 2000+ Tested with: 6.1.4 PHP Version: 5.6
Included Shortcodes:
  • [ce_template]
  • [ce_current_year]
  • [ce_site_title]

Cowidgets – Elementor Addons [ce_template] Shortcode

The Cowidgets-Elementor-Addons plugin shortcode ‘ce_template’ is designed to render templates by their ID. It first checks if the ID attribute is provided. If not, it returns an empty string. If an ID is provided, it checks for the existence of Elementor classes and instantiates the appropriate CSS file. The CSS file is then enqueued, and the Elementor frontend displays the builder content for the given ID.

Shortcode: [ce_template]

Parameters

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

  • id – Unique ID used to render specific Elementor templates

Examples and Usage

Basic example – Display a template by referencing its ID using the ‘ce_template’ shortcode.

[ce_template id=1 /]

Advanced examples

Use the ‘ce_template’ shortcode to display a template by referencing its ID. If the ID is not found or is empty, the shortcode will return an empty string.

[ce_template id=2 /]

It’s also possible to use the ‘ce_template’ shortcode without specifying an ID. In such cases, the shortcode will return an empty string. This can be useful in situations where you want to conditionally display a template based on certain criteria.

[ce_template /]

Lastly, note that the ‘ce_template’ shortcode will automatically enqueue the CSS file associated with the specified template. This ensures that the template’s styles are correctly applied when it is displayed.

PHP Function Code

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

Shortcode line:

add_shortcode( 'ce_template', [ $this, 'render_template' ] );

Shortcode PHP function:

function render_template( $atts ) {
		$atts = shortcode_atts(
			[
				'id' => '',
			],
			$atts,
			'ce_template'
		);

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

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

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

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

Code file location:

cowidgets-elementor-addons/cowidgets-elementor-addons/inc/class-cowidgets.php

Cowidgets – Elementor Addons [ce_current_year] Shortcode

The Cowidgets-Elementor-Addons plugin shortcode ‘ce_current_year’ dynamically displays the current year. It retrieves the current year using the gmdate function and returns it. This is handy for copyright notices, ensuring your site always displays the current year.

Shortcode: [ce_current_year]

Examples and Usage

Basic example – The shortcode ‘ce_current_year’ is used to display the current year on a WordPress page or post.

[ce_current_year /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'ce_current_year', [ $this, 'display_current_year' ] );

Shortcode PHP function:

function display_current_year() {

		$ce_current_year = gmdate( 'Y' );
		$ce_current_year = do_shortcode( shortcode_unautop( $ce_current_year ) );
		if ( ! empty( $ce_current_year ) ) {
			return $ce_current_year;
		}
	}

Code file location:

cowidgets-elementor-addons/cowidgets-elementor-addons/inc/widgets-manager/widgets/header/class-copyright-shortcode.php

Cowidgets – Elementor Addons [ce_site_title] Shortcode

The Cowidgets-Elementor-Addons plugin shortcode, ‘ce_site_title’, is designed to display the title of your website. This shortcode retrieves the site title using the ‘get_bloginfo’ function. If the title exists, it returns and displays it on your page.

Shortcode: [ce_site_title]

Examples and Usage

Basic example – Utilize the shortcode to display the title of your site.

[ce_site_title /]

Advanced examples

While the given shortcode does not accept any parameters, you can modify the function to accept parameters such as ‘before’ and ‘after’. This will allow you to customize the text that appears before and after the site title.

Here is an example of how you might modify the function to accept these parameters:


function display_site_title( $atts ) {

    $args = shortcode_atts( array(
        'before' => '',
        'after' => '',
    ), $atts );

    $ce_site_title = get_bloginfo( 'name' );

    if ( ! empty( $ce_site_title ) ) {
        return $args['before'] . $ce_site_title . $args['after'];
    }
}

And here is how you would use the updated shortcode with the ‘before’ and ‘after’ parameters:

[ce_site_title before="Welcome to " after=" - Enjoy your stay!"/]

In this example, if your site title was “My Site”, the shortcode would output “Welcome to My Site – Enjoy your stay!”.

PHP Function Code

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

Shortcode line:

add_shortcode( 'ce_site_title', [ $this, 'display_site_title' ] );

Shortcode PHP function:

function display_site_title() {

		$ce_site_title = get_bloginfo( 'name' );

		if ( ! empty( $ce_site_title ) ) {
			return $ce_site_title;
		}
	}

Code file location:

cowidgets-elementor-addons/cowidgets-elementor-addons/inc/widgets-manager/widgets/header/class-copyright-shortcode.php

Conclusion

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