WP-EMail Shortcodes

Below, you’ll find a detailed guide on how to add the WP-EMail Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the WP-EMail Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the WP-EMail Plugin and the shortcodes it provides:

Plugin Icon
WP-EMail

"WP-Email is a dynamic WordPress plugin that allows users to send and share your blog's content via email, enhancing engagement and reach."

★★★★✩ (11) Active Installs: 4000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [email_link]
  • [donotemail]

WP-EMail [email_link] Shortcode

The ’email_link’ shortcode from the WP-Email plugin enables an email link within a post. This allows readers to email the post directly from the site. When executed, it checks if the content is not part of a feed. If true, it returns an email link. However, if the content is part of a feed, a note is displayed, prompting users to visit the post to email it.

Shortcode: [email_link]

Examples and Usage

Basic example – Embeds an email link within the post, which can be accessed by visiting the post directly.

[email_link /]

Advanced examples

Embed an email link within the post with a custom message for feed readers. The custom message will be displayed instead of the default message for feed readers.

[email_link message="Custom message for feed readers" /]

Display a different message for feed readers and non-feed readers by using the ‘feed’ and ‘non_feed’ attributes. The ‘feed’ attribute specifies the message for feed readers, while the ‘non_feed’ attribute specifies the message for non-feed readers.

[email_link feed="Message for feed readers" non_feed="Message for non-feed readers" /]

PHP Function Code

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

Shortcode line:

add_shortcode('email_link', 'email_link_shortcode');

Shortcode PHP function:

function email_link_shortcode($atts) {
	if(!is_feed()) {
		return email_link('', '', false);
	}

	return __('Note: There is an email link embedded within this post, please visit this post to email it.', 'wp-email');
}

Code file location:

wp-email/wp-email/wp-email.php

WP-EMail [donotemail] Shortcode

The ‘donotemail’ shortcode is a simple yet powerful tool in the WP-Email plugin. It enables users to exclude specific content from emails. The PHP function ’email_donotemail_shortcode’ processes any content placed within this shortcode, preventing it from being included in the email. This is particularly useful for excluding elements such as images or links that may not display correctly in certain email clients.

Shortcode: [donotemail]

Examples and Usage

Basic example – The basic usage of the ‘donotemail’ shortcode doesn’t require any parameters. It simply runs the content inside the shortcode.

[donotemail]Your content here[/donotemail]

Advanced examples

Using the ‘donotemail’ shortcode with parameters allows for greater flexibility. The parameters are passed to the shortcode as attributes, and can then be used within the shortcode. In the example below, we’re passing two parameters, ‘name’ and ’email’.

[donotemail name="John Doe" email="johndoe@example.com"]Your content here[/donotemail]

It’s also possible to pass additional parameters to the shortcode. In the following example, we’re passing a ‘subject’ parameter as well.

[donotemail name="John Doe" email="johndoe@example.com" subject="Hello, John!"]Your content here[/donotemail]

PHP Function Code

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

Shortcode line:

add_shortcode('donotemail', 'email_donotemail_shortcode');

Shortcode PHP function:

function email_donotemail_shortcode($atts, $content = null) {
	return do_shortcode($content);
}

Code file location:

wp-email/wp-email/wp-email.php

Conclusion

Now that you’ve learned how to embed the WP-EMail Plugin shortcodes, 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 *