M Chart Shortcode

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

Before starting, here is an overview of the M Chart Plugin and the shortcodes it provides:

Plugin Icon
M Chart

"M Chart is a powerful WordPress plugin that allows users to create and manage detailed charts effortlessly. Its user-friendly interface ensures seamless chart creation and customization."

★★★★☆ (27) Active Installs: 4000+ Tested with: 6.2.3 PHP Version: false
Included Shortcodes:
  • [chart]

M Chart [chart] Shortcode

The m-chart shortcode is a tool for embedding charts in your WordPress site. It uses the ‘chart’ shortcode to call a specific chart by its ID. The shortcode function checks if the chart ID is valid, confirms that the chart exists, and ensures it’s published before rendering it on the page.

Shortcode: [chart]


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

  • id – The unique number that identifies the specific chart.

Examples and Usage

Basic example – Represents a simple execution of the m-chart plugin shortcode, where we only specify the ID of the chart we want to display.

[chart id=1 /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'chart', array( $this, 'chart_shortcode' ) );

Shortcode PHP function:

function chart_shortcode( $args ) {
		$default_args = $this->get_chart_default_args;
		$default_args['id'] = '';

		$args = shortcode_atts( $default_args, $args );

		$post_id = $args['id'];
		unset( $args['id'] );

		// Did we get a chart ID?
		if ( ! is_numeric( $post_id ) ) {

		// Make sure the chart actually exists and that it's a chart so we don't fatal later
		if ( $this->slug != get_post_type( $post_id ) ) {

		// Is it published?
		if ( 'publish' != get_post_status( $post_id ) ) {

		return $this->get_chart( $post_id, $args );

Code file location:



Now that you’ve learned how to embed the M Chart 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

Your email address will not be published. Required fields are marked *