# 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="https://157604815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJfBhHG_1ipE5lMX4qT%2Fuploads%2FkJjCX7yGDKX0U9xvg51c%2FScreenshot_1.png?alt=media&#x26;token=1f97b26e-c294-48c3-bf05-52789748b66e" 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="https://157604815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJfBhHG_1ipE5lMX4qT%2Fuploads%2FXwQgA5mnmIrrqTnvJb2X%2Fimage%20(32).png?alt=media&#x26;token=d0db2f6e-903a-465c-a644-00eff38cfec4" 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="https://157604815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJfBhHG_1ipE5lMX4qT%2Fuploads%2FJAOytmXMXzmQgg3IOStu%2FScreenshot_2.png?alt=media&#x26;token=f571812c-ce1e-4924-baf9-73af300e2ab6" alt=""><figcaption><p>YayMail Custom shortcodes</p></figcaption></figure>
