Depicter Shortcode

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

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

Plugin Icon
Depicter Slider – Responsive Image Slider, Video Slider & Post Slider

"Depicter Slider is a versatile WordPress plugin offering responsive image, video & post sliders. Perfect for enhancing visual appeal and showcasing content in a dynamic, engaging way."

★★★★☆ (141) Active Installs: 70000+ Tested with: 6.2.3 PHP Version: 7.2.5
Included Shortcodes:
  • [depicter]

Depicter [depicter] Shortcode

The Depicter plugin shortcode is designed to process and render documents. It extracts shortcode attributes, identifies the document ID, and returns the rendered document.

Shortcode: [depicter]

Parameters

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

  • id – The unique identifier for the document.
  • slug – The alternate identifier for the document if ‘id’ is empty.
  • alias – If both ‘id’ and ‘slug’ are empty, ‘alias’ is used as the document identifier.

Examples and Usage

Basic example – A shortcode to display a document using its ID.

[depicter id="123" /]

Advanced examples

Displaying a document using its alias instead of ID. If the document with the given ID is not found, the plugin will try to render the document using the alias.

[depicter alias="document-alias" /]

Displaying a document using both ID and alias. The plugin will first try to render the document using the ID, if not found, it will then try to render the document using the alias.

[depicter id="123" alias="document-alias" /]

Displaying a document using its slug. If the document with the given ID or alias is not found, the plugin will try to render the document using the slug.

[depicter slug="document-slug" /]

Displaying a document using both ID and slug. The plugin will first try to render the document using the ID, if not found, it will then try to render the document using the slug.

[depicter id="123" slug="document-slug" /]

PHP Function Code

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

Shortcode line:

add_shortcode(self::SHORTCODE_NAME , [ $this, 'process_shortcode' ]);

Shortcode PHP function:

function process_shortcode( $attrs, $content = null ) {

		extract( shortcode_atts(
			array_fill_keys( self::SHORTCODE_ATTRS, '' ),
			$attrs,
			'depicter'
		));

		$documentId = $id;

		if ( empty( $documentId ) ) {
			if( empty( $slug ) && ! empty( $alias ) ){
				$slug = $alias;
			}
			$documentId = $slug;
		}

		return \Depicter::front()->render()->document( $documentId, [ 'echo' => false ] );
	}

Code file location:

depicter/depicter/app/src/WordPress/ShortcodesServiceProvider.php

Conclusion

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