Garden Gnome Package Shortcode

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

Before starting, here is an overview of the Garden Gnome Package Plugin and the shortcodes it provides:

Plugin Icon
Garden Gnome Package

"Garden Gnome Package is a dynamic WordPress plugin that transforms your website into a green paradise. It offers unique features for gardening enthusiasts, providing a visually appealing and interactive experience."

★★★★✩ (5) Active Installs: 5000+ Tested with: 6.3.2 PHP Version: 5.6
Included Shortcodes:
  • [ggpkg]

Garden Gnome Package [ggpkg] Shortcode

The Garden Gnome Package (ggpkg) shortcode is designed to generate HTML code for a specific package. This shortcode accepts attributes like ‘id’, ‘url’, ‘start_preview’, ‘width’, ‘height’, ‘start_node’, and ‘start_view’. The ‘id’ or ‘url’ attribute is used to locate the package. ‘start_preview’ enables a preview mode. ‘width’ and ‘height’ set dimensions, while ‘start_node’ and ‘start_view’ define the initial display state.

Shortcode: [ggpkg]


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

  • id – Specifies the attachment ID for the package.
  • url – Sets the URL of the package content.
  • start_preview – Decides whether to use the preview of the package.
  • width – Defines the width of the package display.
  • height – Defines the height of the package display.
  • start_node – Sets the starting node for the package.
  • start_view – Sets the initial view of the package.

Examples and Usage

Basic example – A shortcode that displays a garden gnome package by referencing its ID.

[ggpkg id=1 /]

Advanced examples

Using the shortcode to display a garden gnome package by referencing its URL. The package will load from the specified URL.

[ggpkg url="" /]

Using the shortcode to display a garden gnome package with specific width and height. This will customize the size of the displayed package.

[ggpkg id=1 width="500" height="300" /]

Using the shortcode to display a garden gnome package with a specific starting node and view. This will control the initial display of the package.

[ggpkg id=1 start_node="node1" start_view="view1" /]

Using the shortcode to display a garden gnome package with a preview start. This will initiate the package with a preview.

[ggpkg id=1 start_preview="true" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'ggpkg', array( $this, 'shortcode' ) );

Shortcode PHP function:

function shortcode( $attributes ) {
		global $post;
		$attachmentID = isset( $attributes['id'] ) ? $attributes['id'] : false;
		$package      = new GGPackage( $this );

		if ( isset( $attributes['url'] ) ) {
			$url = $attributes['url'];
			$url = str_replace( '/index.html', '/', $url );
			if ( substr( $url, - 1 ) != '/' ) {
				$url = $url . '/';
			if ( parse_url( $url, PHP_URL_SCHEME ) == '' ) {
				$url = home_url( $url );
			$package->set_from_url( $url );
		} elseif ( $attachmentID ) {
			$package->from_attachment( $attachmentID );
		if ( isset( $attributes['start_preview'] ) ) {
			$package->use_preview = $this->attribute_set_true( $attributes['start_preview'] );
		if ( isset( $attributes['width'] ) ) {
			$package->width = trim( $attributes['width'] );
		if ( isset( $attributes['height'] ) ) {
			$package->height = trim( $attributes['height'] );
		if ( isset( $attributes['start_node'] ) ) {
			if ( preg_match( "/((\w{1,10}))$/", $attributes['start_node'] ) ) {
				$package->start_node = trim( $attributes['start_node'] );
		if ( isset( $attributes['start_view'] ) ) {
			if ( preg_match( "/(([\w\,\|\/]{0,30}))$/", $attributes['start_view'] ) ) {
				$package->start_view = trim( $attributes['start_view'] );

		return $package->get_html_code( $post->ID );

Code file location:



Now that you’ve learned how to embed the Garden Gnome Package 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 *