• I have tried several ways to create a subscription widget that creates an email list, and then when I post a new blog post, the list gets a notification. I have tried Mail chimp, Mail poet, and Icegram, and for some reason I can’t get an email sent when I post something new. I am clueless as to what’s wrong.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @faiths13

    You have to go with WordPress hook. If you are wanting to only send an email on a new post I would consider targeting when the post is published. You could even look at the?transition_post_status?hook and just conditionalize if the post has been edited, something like this could work:

    function so_post_40744782( $new_status, $old_status, $post ) {
        if ( $new_status == 'publish' && $old_status != 'publish' ) {
            $recipients = "[email protected],[email protected]";
            $message = "We wanted to notify you a new post has been published.";
            wp_mail($recipients, "New Post Published", $message);
        }
    }
    add_action('transition_post_status', 'so_post_40744782', 10, 3 );

    In the $recipients variable, you need to fetch all your emails and put them separated by a comma.

    Hope it will help you

    Thread Starter faiths13

    (@faiths13)

    I’m sorry, I don’t understand that.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Sending Emails For New Posts’ is closed to new replies.