# 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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yaycommerce.com/yaymail/drag-and-drop-email-builder/upper-area-of-the-editor-screen/custom-shortcode.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
