Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Having discussed concepts, let's look at using WordPress to automate the creation of emails. To automate email newsletters with WordPress, we will follow these steps. We will create a category called Newsletter, and we will get the ID. We will create posts, tag each post with the Newsletter category, and add custom fields, two of them: one called explore link icon and the other, image thumbnail. Third, we will create a template with the name Email Newsletter. We will use query_post to display their most recent entries tagged with category Newsletter.
And finally, we will create a page, we will assign the template Email Newsletter to that page, and we will publish. Let's look at each of these steps now. The first step is to create a category called Email or Email Newsletter. In this case we've used the phrase Email Newsletter. If we click the Email Newsletter link, we see the Edit Category page, and up in the URL there is a value call tag_ID =3. This is WordPress's unique ID for this category. We will need this later when we code or template. For now, let's remember the ID for this category is 3.
The second step will be to create a post. We have a post here, Cycle California Tours, and if you recall, this is the two- column email that we will automate, and we had, for each tour, a logo, a description, and a link to explore more information about that tour. Now, we will replicate that a little bit. We will create a post for the Cycle Tour. Once we have our copy in the Edit box, then we go over to Categories, we select the Email Newsletter, we scroll down, and we create two custom fields. One is called to EXPLORE Link Icon, and that refers to the EXPLORE Link with the little start.
The stars are either blue or red or gray. In this case, our Custom Field, explore link icon, we'll choose red. The second Custom Field we add is Image Thumbnail. This corresponds to the Cycle Tours logo here. To get the value for the image thumbnail, we upload the image using WordPress's Add an Image pop-up. Since we've already added it, it's in our gallery. There is the logo. We scroll down.
We look for the link URL. We highlight it, Copy, close Add an Image pop-up, scroll down, and now we have a value for our image thumbnail Custom Field, and we click Update. So now we have a post that is one tour description with its logo image and a choice of explore button. We've also tagged it with the Email Newsletter category, and we've added to custom fields, one to define the explore button we want and the other to define the thumbnail logo that we want to use.
The next step is to work on the template. If you recall, our category ID was the number 3. So when we scroll down, in PHP we are using the query_posts function. We use showposts. We want four posts. If you recall our original email, we had one, two, three, and four tours, so we have four posts. Our category ID is the number 3, which we retrieved earlier. The next thing in our code does is retrieve the custom field for image thumbnail.
We've typed in here the custom field name as it appeared on the post form we saw moment ago. We retrieved the explorer icon, which works exactly the same way as the image thumbnail. You type in the custom field name as it appears on the post form. Then we retrieve the excerpt, and because the excerpt comes packaged with a paragraph tag, HTML p tag, before and after the excerpt, we need to remove that, because in our HTML email, it will mess up our formatting. Once we have our image thumbnail, then we build the actual image code for our logos.
Then we use a custom field to define the explore button to define which image to call. In this case, it's red, so we know that the explore red button will appear. Finally, we have one instance of our table that contains tour logo, the tour description, and the explore link. And within this one instance, we have PHP code to display the thumbnail at the right spot, display the tour description as an excerpt at the right spot, and then the permaLink at the right spot.
Finally, with our template, so that we can find it with the page, at the very top of the template we define the template name as Email Newsletter. The last step is to create a page. We have a page called Newsletter. When we open it, we have selected a template over here on the right called Email Newsletter, and when we update it, you see that we have automated the two-column HTML email with WordPress using the first post. If you want to see a little bit about how this works, we will go back to our post.
We will use the blue explorer icon. We will update it, update our post. Now we have the red explorer icon. Now we have the blue. This video only shows a general way to automate the creation of emails with WordPress. You will to need to refer to other online documentation for the software if you want or need more technical details.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 74673 Viewers
80 Video lessons · 129823 Viewers
52 Video lessons · 64025 Viewers
59 Video lessons · 49815 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.