Hello @thecaleb ,
We hope this message finds you well.
Thank you for reaching out to our Support team. To set up email notifications for new blog posts, you can use one of the following methods:
- Using a Plugin: You can install a plugin designed for this purpose, which will allow you to configure email notifications with ease.
- Adding Custom Code: If you prefer a more customized approach, you can add the following code snippet to the
functions.php file of your theme. To do this, navigate to Tools > Theme File Editor in your WordPress dashboard:
function notify_admin_on_post_publish( $ID, $post ) {
$admin_email = get_option( 'admin_email' ); // Get the site admin's email
$subject = 'A new post has been published!';
$message = 'Hello Admin,' . "\n\n" .
'A new post has been published on your website:' . "\n\n" .
'Title: ' . $post->post_title . "\n" .
'View it here: ' . get_permalink( $ID ) . "\n\n" .
'Thanks!';
// Send the email
wp_mail( $admin_email, $subject, $message );
}
add_action( 'publish_post', 'notify_admin_on_post_publish', 10, 2 );
This code will automatically send an email notification to the admin whenever a new blog post is published.
If you have any questions or need further assistance, please don’t hesitate to reach out. We’re here to help!
Warm regards,
Support Team – WP Experts