> For the complete documentation index, see [llms.txt](https://docs.yaycommerce.com/yaymail/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yaycommerce.com/yaymail/drag-and-drop-email-builder/upper-area-of-the-editor-screen/custom-shortcode.md).

# Custom shortcode

You can also create your own shortcodes using filter by adding shortcode name with prefix: **yaymail\_custom\_shortcode\_\['name']** in file functions.php of your site's theme.

{% hint style="warning" %}
**Note:**\
Custom shortcode must use the prefix: **yaymail\_custom\_shortcode\_\['name'].**\
Custom shortcodes only work in emails when you place an actual order, they do not work when you send test emails.
{% endhint %}

Example 1:&#x20;

<figure><img src="/files/iuIY907wsDqPsHoL4JUe" alt=""><figcaption></figcaption></figure>

You can copy the code from here:

```
add_filter(
    'yaymail_customs_shortcode',
    function( $shortcode_list, $yaymail_informations, $args = array() ) {
        $shortcode_list['[yaymail_custom_shortcode_new_order]']        = 'Custom shortcode test New order';
        $shortcode_list['[yaymail_custom_shortcode_processing_order]'] = 'Custom shortcode test Processing order';
        $shortcode_list['[yaymail_custom_shortcode_order_on_hold]']    = 'Custom shortcode test Order on hold';
        return $shortcode_list;
    },
    10,
    3
);
```

Example 2:

<figure><img src="/files/ajNI4s0LgXh6MXwsMrV7" alt=""><figcaption></figcaption></figure>

You can copy the code from here:

```
function test_shortcode1(  $shortcode_list, $yaymail_informations, $args = array() ) {
	//It only runs when tested with real order
	if (isset ($args['order'])) {
		$order = $args['order'];
		$order_id = $order->get_id();
		return $order_id;
	}
	
	// in Yaymail will show it
	return 'test_shortcode';
}

add_filter(
	'yaymail_customs_shortcode',
	function( $shortcode_list, $yaymail_informations, $args = array() ) {
			$shortcode_list['[yaymail_custom_shortcode_test]']            = test_shortcode1($shortcode_list, $yaymail_informations, $args);
		return $shortcode_list;
	},
	10,
	3
);
```

You can see your custom shortcodes in the list here.&#x20;

<figure><img src="/files/4S8eeNFCxQRhgrcG4GEo" alt=""><figcaption><p>YayMail Custom shortcodes</p></figcaption></figure>
