How to mail new posts wordpress
In WordPress, there are a few ways to send notifications or emails when a new post is published. Here are a few methods:
Method 1: Using the built-in WordPress feature
- Go to Settings > Writing in your WordPress dashboard.
- Scroll down to the Email Options section.
- Check the box next to Send a notification email to the author.
- Enter the email address(es) you want to receive notifications at.
- Click Save Changes.
This will send an email to the author of the post when it's published, with a summary of the post and a link to view it.
Method 2: Using a plugin
There are many plugins available that can help you send notifications or emails when a new post is published. Here are a few popular ones:
- WP Notification Email: This plugin allows you to send custom email notifications to authors, editors, or administrators when a new post is published.
- Post Notification: This plugin sends email notifications to authors, editors, or administrators when a new post is published, and also allows you to customize the notification content.
- Notify Me: This plugin sends email notifications to authors, editors, or administrators when a new post is published, and also allows you to customize the notification content and recipients.
To use a plugin, follow these steps:
- Install and activate the plugin in your WordPress dashboard.
- Configure the plugin settings to your liking.
- Save your changes.
Method 3: Using a custom function
If you're comfortable with coding, you can also use a custom function to send notifications when a new post is published. Here's an example:
function send_new_post_notification($post_id) {
$post = get_post($post_id);
$author_email = get_the_author_meta('email', $post->post_author);
$subject = 'New Post: '. $post->post_title;
$message = 'Hello, '. $post->post_author. '. Your new post "'. $post->post_title. '" has been published.';
wp_mail($author_email, $subject, $message);
}
add_action('publish_post', 'send_new_post_notification');
This code uses the publish_post
action hook to trigger the send_new_post_notification
function when a new post is published. The function gets the post author's email address, constructs a subject and message, and sends an email using the wp_mail
function.