Thursday, October 15, 2020

How to Build an Email List in WordPress – Email Marketing 101

Do you want to create an email list in WordPress?

Email marketing is the best way to stay in touch with your readers. And it’s much more effective for reaching your audience than social media alone.

In this email marketing guide for beginners, we’ll show you how to easily build an email list in WordPress.

How to build an email list in WordPress

Because this is a longer article, we put together a table of contents below to navigate each section.

What is an Email List?

An email list is a group of people who’ve requested to get regular email updates from you. Typically, people get onto your email list by adding their information in an opt-in form on your site.

Building an email list allows you to stay in touch with your readers and customers by using an email marketing software.

And because email is a reliable form of communication, you can easily let your readers know about anything coming up, such as new products, sales, or special announcements.

Why Email Marketing is Important?

On our websites, email marketing outperforms social media marketing in the number of clicks.

We have tested this repeatedly and the result is always the same: Emails get us 10 times more clicks than all social media combined.

But why does email perform so well? The answer is simple: email is private and personal.

If this is not a good enough reason to start building your email list, here are some major benefits.

  • Guaranteed Reach – When you use Twitter, Facebook, or Instagram, your updates are bound to be missed due to the very nature of social media algorithms. However, people tend to check emails a lot more carefully than their social networks.
  • Access and Ownership – You don’t own the content you post on social media. At any time, your account can be suspended and you lose all your followers. Or what if your favorite social media platform goes out of business? We’re not saying they will, but your email list is something that you own. Second, you are not limited to the rules of the social platform, such as character length or hashtag rules. You set the limits yourself. You can integrate email newsletters within your WordPress blog with more effectiveness than embedding social platforms (we will show you how later in this guide).
  • Better Targeting – The best part about building your email list is that you can use it to target your audience locally (for folks in specific countries, cities, states). If you are launching a product in select locations, then email is the best way to reach your subscribers in that area.
  • Increase Revenue – The bottom line is when you have guaranteed reach, better targeting, and attention of your users, then you are definitely going to increase revenue.

But isn’t email dead? Haven’t you heard social media is where everyone’s at?

It’s a common statement but if email use was truly dead, then why does every social media platform require you to sign up with an email address?

Email has been the most reliable form of electronic communication for the past two decades, and it hasn’t slowed down. Plus, building an email list is a lot easier than building a following on social media platforms.

Facebook and Instagram both limit the reach of your pages to a small percentage of your followers unless you want to pay for ads. Similarly, your tweets only appear for a limited time on a user’s feed.

On the other hand, when you send an email, it reaches all your subscribers and stays in their inbox until they take action.

We are not saying you should abandon social media. These sites are great for building user engagement, but email will bring you more visitors, conversions, and sales.

Lastly, a social media site can disappear or become less popular (remember Myspace?). When they disappear, they will take your followers with them.

On the other hand, email has been around since the dawn of the internet. And it’s still the most popular way people communicate online.

How to Get Started Building Your Email List

The first thing you need is a reliable email service provider.

These companies specialize in email delivery, and you need them to ensure your email reaches the inbox of all your subscribers (instead of having your email marked as spam).

Even though you can use WordPress to send emails, we strongly recommend against that (see why you should never use WordPress to send email newsletters).

These professional email service providers spend a lot of money and resources on their email delivery infrastructure to make sure that your email does not end up in your subscriber’s junk folder.

All major companies like Facebook, Apple, eBay, and Amazon use a third-party email marketing service.

Apart from deliverability, these companies also provide you with email marketing tools that you’ll need to make your emails more effective.

Which Email Marketing Service Should You Use?

There are many great email marketing providers out there.

It’s a very competitive industry which means companies are always trying to keep their costs low while offering a lot of features.

Below are just some of the providers that we have worked with and highly recommend.

Build Your Email List with Email Marketing Software

Constant Contact is the best email marketing service provider for all sizes of businesses and websites.

It lets you send emails, manage subscribers, track emails, view analytics, set up autoresponders, create beautiful email templates, target subscribers, and split test your campaigns.

This software allows you to capture email addresses, works easily with WordPress, and has integrations for all the top WordPress plugins and tools.

Constant Contact homepage

The best part is that Constant Contact comes with a two-month free trial. This gives you enough time to set up your email list and start capturing email addresses.

By the end of the trial, your list will be paying for itself. Sign up for FREE!

Other alternatives are SendinBlue, Drip, and ConvertKit. They all work well with WordPress and are easy to use for beginners.

For the sake of this guide, we’ll show you how to set up an email list using Constant Contact. However, the process is quite similar regardless of which email service you choose.

Create Your Email List in Constant Contact

Let’s set up your email list. This is simply a list where you will store contact information of all users who sign up for your email newsletter.

Go to the Constant Contact website and click on ‘sign up for free’, and then fill out your information.

After the sign up, you need to click on the ‘Contacts’ button at the top of your Constant Contact dashboard.

Contacts button in Constant Contact

Now, you’ll see the contacts page. On this screen, click on the blue ‘Create List’ button.

Create your Constant Contact list

At this step, it’s time to name your email list. It can be whatever you want, but we’ll call it ‘My Email List’ for this example.

Name your Constant Contact email list

You’re done creating your list people can subscribe to. The next step is to add an email subscription form to your WordPress website where your readers can sign up.

For more details on setting up your email list, see our guide on how to add email subscriptions to your WordPress blog.

Add Subscribers To Your Email List with WPForms

While Constant Contact comes with an email signup form builder, the fastest way to get started is to use the WPForms. It integrates seamlessly with Constant Contact to set up an optin form easily.

First, you need to install and activate the WPForms plugin. If you need help, then follow our guide on how to install a plugin for detailed instructions.

Note: There is also a free version called WPForms Lite, which includes Constant Contact support but it has limited features.

Upon activation, head over to the WPForms » Add New page and then select the ‘Newsletter Signup Form’ template.

Add new WPForm

You’ll see a sample newsletter signup form inside the form builder interface.

On the next page, you’ll get a notice to connect your email marketing service in the marketing tab. More on that in a second.

Make sure to change the name of your form by clicking on the title. For this example, we called it ‘Subscribe For Regular Updates’ but you can name it whatever you want.

Click on the orange ‘SAVE’ button. Now, you’ll want to set up your confirmation message. Click on ‘Confirmations’ on the left under ‘General’ and we’ll update that.

You’ll see this:

WPForms confirmation message

The default confirmation message reads “Thanks for contacting us! We will be in touch with you shortly.” but you can put anything here you want. This is the message your readers will see after they subscribe to your newsletter.

Now, click the marketing tab on the left:

WPForms marketing tab

Now, you’ll see the ‘Constant Contact’ button. Click that to connect your new email list to the form we’ve created.

WPForm email list connection

For the next step, click on the ‘Add New Connection’ button and you’ll see a popup that asks you to name your connection. We’ve named it ‘My Newsletter Form’ but you can name it anything you wish.

After that, you’ll see this:

Register your form

Click on ‘Click here to register with Constant Contact’ link to enter your Constant Contact details. Now, you’ll see a message that asks you to let WPForms to access your account. Click on the ‘Allow’ button to continue.

You’ll be given a long authorization code to register your form.

WPForm authorization code

Enter your code, along with the account nickname (make sure it’s something that is familiar) into those fields. Click ‘Connect’ and you’re done.

On the next screen, you can select the fields you want to pass from your WPForm to your Constant Contact list. We chose ‘email’ and ‘full name’ but you can select as many as you want.

Just be sure those two fields are on your optin form.

Email fields

Click the big orange ‘Save’ button when you’re done.

Now your form is set up and it’s time to place it on our WordPress website. For this example, we’ll put it in the sidebar.

Go to Appearance » Widgets page to add the WPForms widget to your sidebar.

Add WPForm widget to sidebar

Give your widget a title and select your newsletter sign-up form. Click on the ‘Save’ button to store your widget settings.

When you visit your website, you’ll see your email subscription form in the sidebar.

Form in the sidebar

Now, any time someone inputs their name and email into your form, they’ll be added to your email list.

Grow Your Email List Faster with OptinMonster

Did you know that more than 70% of your website visitors will never visit it again? The Internet is just too big and there are tons of websites and competition is fierce in most industries.

You get just a few seconds to convince a website visitor to stay and look around.

This is where OptinMonster comes in. It is the best conversion optimization software in the world and allows you to easily convert website visitors into subscribers and customers.

OptinMonster homepage

With this optin software, you can set up welcome mats, exit-intent popups, slide-in forms, floating bars, and more optin styles to capture the most email subscribers possible.

From there, you can customize your form in style, and use smart targeting rules to display it at the precise time and location.

OptinMonster exit-intent popup

Here’s an example of a subtle and polite slide-in form used on the OptinMonster blog:

OptinMonster slide-in

One thing here is key: user experience. At WPBeginner, we have successfully used this lightbox popup and noticed a 600% increase in our subscribers without affecting the user experience or seeing any decrease in pageviews.

OptinMonster comes with a 14-day money back guarantee, so if you use it and don’t see an increase in your subscribers, then you can get a full refund.

Interacting with Your Subscribers

Once you’ve started building your email list, it’s crucial that you engage with your subscribers.

Ideally, you’ll make it a habit to send them regular emails, whether it’s weekly or monthly.

Not every email has to be promotional. You can send emails requesting feedback, giving helpful tips, or letting them know of new content you’ve created.

We hope this article helped you learn how to build an email list in WordPress. You may also like our list of tested and easy ways to grow your email list faster, and our proven tips on how to grow your website traffic.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Build an Email List in WordPress – Email Marketing 101 appeared first on WPBeginner.


October 15, 2020 at 05:30PM

Tuesday, October 13, 2020

How to Add Web Push Notification to Your WordPress Site

Do you want to add push notifications to your WordPress site?

Push notifications let you send messages to users even when they are not visiting your website. This helps you bring back users to your website, increase traffic, and make more money.

In this article, we will show you how to easily add web push notifications to your WordPress site.

Adding web push notifications to a WordPress website

What are Push Notifications?

Push notifications are short, clickable notification messages that appear as a popup on users’ desktop or mobile devices.

They appear on top of the desktop or in the notification area on their mobile device. The best thing is that they can be shown even when the user’s browser is not open.

Here’s an example of a push notification in Windows 10:

The welcome / thank you notification message, as seen by the user

Push notifications let you reach users across devices with your latest updates and offers. Web push notifications are a very effective way to convert website visitors into loyal followers and customers.

Why Add Web Push Notifications to Your WordPress Site?

Did you know that 70% of people who leave your website will never come back? This is why you need to convert those website users into subscribers or customers.

You can do this by using multiple channels at once. This includes email marketing, social media, mobile or SMS marketing, and web push notifications.

Email lists are still the most powerful marketing tool available. However, we are finding that push notifications are also very effective.

On WPBeginner site, push notifications are consistently the top 5 traffic source.

The following are just some of the reasons that make push notifications a great marketing tool:

  • Users need to give their explicit permission to receive push notifications. This means they are already interested in what you have to offer and are more likely to engage with notifications.
  • Push notifications are shorter and demand less attention than email or social media updates.
  • There is no algorithm like on social media to limit your reach. Nearly 100% of messages are delivered.
  • Users can control how their devices display notifications. They can snooze them or turn them off entirely.
  • Not as many companies are using push notifications.

Popular sites including Facebook, Pinterest, LinkedIn, and many others understand the importance. They are already using web push notifications.

According to a survey, push notifications have a 50% higher open rate than email and twice as much click-rate. They are more engaging than SMS, email marketing, and social media platforms.

Having said that, let’s take a look at how to easily add web push notifications to a WordPress site.

Setting up Web Push Notifications in WordPress with PushEngage

PushEngage is the best push notification service on the market. It allows you to easily add push notifications to your WordPress site.

We’re in the process to switching to PushEngage for WPBeginner, so we can leverage their powerful automatic user segmentation features to further boost our engagement.

Creating Your PushEngage Account

First, you need to go to the PushEngage website and click the Get Started For Free button:

Click the Get Started button to create your PushEngage account

The free plan covers you for up to 2,500 subscribers and 120 notification campaigns each month. You’ll need to upgrade as you get more subscribers and need to send more campaigns.

Enter your account details or use your Google Account to sign up for PushEngage

Upon sign up, you will reach the PushEngage dashboard. If you signed up using your Google account, PushEngage will prompt you to enter your website details:

Updating your site name and URL after creating your PushEngage account

You should now see the Settings » Site Settings » Installation Settings page in your PushEngage dashboard.

Here, you need to upload an image to use in your push notifications. Go ahead and click the ‘Change’ button below the empty image box.

Adding your logo image to PushEngage

Your image needs to be in PNG or JPG file format and the recommended size is 256x256px. This image will display in your push notifications.

You’ve now completed the key information for your PushEngage account.

Connecting Your WordPress Site with PushEngage

The next step is to connect your website to PushEngage.

To do this, you need to install and activate the PushEngage WordPress plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon installation, you also need to download the JavaScript file for PushEngage if your site uses HTTPS. You need to unzip this and upload it to your website’s root folder.

To dowlnoad the file, go to Settings » Site Settings » Installation Settings in your PushEngage account.

Under ‘Choose Website Type and Add Script’, you need to click the WordPress tab. Then, go ahead and click the ‘Download Package File’ button:

Downloading the package file for WordPress

Next, unzip the file on your computer. Simply right-click on it and then select the Extract option:

Extracting the JavaScript file from your downloaded zip file

You should then see the file service-worker.js:

The extracted service-worker.js file shown in a folder on the computer

Now, you need to upload that file to your website’s root folder in your WordPress hosting account. The root folder is the one where all the other folders and files are stored for your site. Normally, it’s the same folder where you’ll see /wp-content/ folder.

Simply connect to your website via FTP and upload the file. For help with this, check out our beginner-friendly guide on using FTP to upload files.

Tip: Not sure if you have the root folder? Look for an index.php file. If you see that, you’re in the right folder.

Uploading the service worker file via FTP

Now that you’ve uploaded the file, you can continue connecting WordPress to PushEngage.

The next step is to get your API key. Simply go to Settings » Site Settings » API Keys in your PushEngage dashboard. Then, go ahead and click the ‘Generate a New API Key’ button:

Generating a new API key to use with PushEngage

You should then see your API key.

Your API key shown in the PushEngage dashboard

In a new tab, go to the PushEngage page in your WordPress admin. Then, click the ‘Setup’ tab. You will see a box for your API key.

Simply enter your API key here, then click the Submit button.

Entering the API key into the PushEngage plugin's Setup page in WordPress

Setting Up Your Push Notification Messages

Now, you will see your PushEngage settings. Check that you’re happy with the General Settings. You can change your account details here or on the PushEngage website:

Viewing your PushEngage dashboard in WordPress

Next, it’s time to set up the message that people will see when they arrive on your website. Just click on the ‘Subscription Dialogbox’ tab to view and change the settings.

Changing the text in your subscription dialogbox

You will see your logo in the message, plus the default text. You can change this to your own message. Don’t forget to click the ‘Update Optin Settings’ button to save your changes.

Make sure you click the update button to save your changes to the subscription dialogbox

Below this, you can change the message that’s shown on the intermediate page. This is the page that appears after the user first clicks Allow.

Note: You can’t change what’s shown in the browser’s own popup box. This will always have the ‘Show notifications’ text plus Allow and Block buttons.

Just type in the text you want to use. Don’t forget to click the ‘Update Page Settings’ button.

Changing the intermediate page text in the PushEngage dashboard

You may want to create a welcome notification to thank people for subscribing. This also lets you easily test that your notifications are working.

Just click on the ‘Welcome Notification Settings’ tab to set it up. Here, you need to type in the title and message for the welcome notification. You can use your homepage as the URL, or you could send users to a specific page.

Make sure you check the ‘Send Welcome Notifications to Subscribers’ box to activate welcome notifications. You also need to click the Update button to save your changes.

Setting up your welcome notification in PushEngage

Testing the Push Notifications on Your Website

Once you’ve set up push notifications, it’s best practice to check that they’re working as you expected.

To test your push notifications, open your website on your computer or phone.

You should immediately see the subscription dialog box that you set up. Here’s ours on a desktop computer:

The subscription dialogbox live on the website

And here’s our subscription dialogbox on a mobile device:

The subscription dialogbox on a mobile

Go ahead and click the ‘Allow’ button. You should then see the intermediate page in a popup window. Here’s how it looks on a computer:

The live view of the intermediate page set up with PushEngage

You need to click ‘Allow’ here too. Now, you’ve successfully subscribed to push notifications from your site.

Your welcome notification should appear on your screen within a few minutes. Here’s ours, showing the welcome message we created earlier:

The welcome / thank you notification message, as seen by the user

What if a user chooses not to enable notifications but later wants to subscribe? This is automatically enabled with PushEngage. The user will see a bell widget in the bottom right corner of your website:

The bell notification widget at the bottom of the demo website

They can simply click on this to subscribe to your website. To change the bell notification widget, simply go to Settings » Subscription Settings » Opt-in Management in your PushEngage account.

You can change the color, position, and label of the widget:

Customizing the bell notification widget in PushEngage

You can even swap the bell for a button that appears along the side of the website like this:

A button notification widget shown on the demo website

Sending Push Notifications to Your Subscribers

By default, PushEngage will send out a notification for each new post. These notifications will include the post title and a small version of the featured image. When a user clicks the notification, they’ll be taken straight to your blog post:

An automatic new post notification, as seen by the user

If you don’t want automatic notifications, then you can turn them off by visiting PushEngage » General Settings in your WordPress dashboard.

Simply scroll down to the ‘WordPress Post Settings’ section and uncheck the ‘Auto Push’ box. Don’t forget to click on the ‘Save WordPress Settings’ button.

Turning off the automatic post notifications in the WordPress PushEngage dashboard

You can create custom notifications at any time in PushEngage. Just log into your account on the PushEngage website then go to Notifications » Create » New Notification.

This screen gives you the option to set the title, message, URL, image, and more. You can schedule notifications to go out at a later time or you can send them immediately.

Tip: If you’re pre-scheduling notifications, make sure your time zone is correct. It’s easy to check or change this under Settings » Site Settings » Site Preferences in your account on the PushEngage website.

We’ve created a special notification for our blog post with a custom title and message.

Creating a new notification in your PushEngage account

Other PushEngage Features to Use for Your Website

PushEngage offers a wide range of other features, even on the free plan.

For instance, you can set up an overlay. This appears on top of your website content and shows the user where to click to allow notifications. Here’s an overlay in action on the PushEngage website:

An example of a PushEngage overlay

You can set up an overlay in your account on the PushEngage website. Simply go to Settings » Subscription Settings » Opt-in Management and scroll down to the ‘Subscription Overlay’ section.

Then, check the ‘Enable Subscription Overlay’ button. You can use the default overlay label or type in a different one:

The subscription overlay settings in PushEngage

Due to the way the Safari browser works, you need to go through some extra steps if you want Safari users to be able to subscribe to your push notifications. To enable web push notifications for Safari, you need an Apple developer account ($99/year). You can then create a unique Push ID for your website.

Once you have your Push ID and you’ve created a certificate, you then need to add these under Settings » Subscription Settings » Safari Web Push:

Setting up web push notifications in Safari

Other Good WordPress Push Notification Plugins

It is important to choose the right web push notification service from the start. Many providers try to lock you into their platform. That means changing your push notification service can mean losing your subscribers. So if you switch, you will be starting again from scratch.

This is why we suggest asking the provider you choose for all settings you need to configure to make your subscriber list portable.

We recommend PushEngage because it has a generous free plan plus lots of powerful paid features. With PushEngage’s paid plans, you can:

  • Set up a drip autoresponder, such as for a welcome campaign
  • Send notifications when a user has abandoned their cart
  • Trigger campaigns based on users’ actions
  • Allow users to add product alerts for when a product goes on sale or is back in stock
  • … and more

WordPress is all about choices. Here are some other WordPress push notification plugins that you may want to try:

  • PushCrew – Connects your website to PushCrew’s push notification service. They offer a free plan limited to 2000 subscribers.
  • PushAlert – Web Push Notifications – Helps you connect to PushAlert web push notification service. They also offer a free plan limited to 3000 subscribers.
  • PushAssist – Connector plugin for the PushAssist web push notification service. Their free plan is limited to 2000 subscribers.
  • OneSignal – Has a limited free plan that includes basic web push notification features. Their upsell tactics are very aggressive and support isn’t helpful. This is why we’re switching away from OneSignal in the coming weeks.

We hope this article helped you learn how to add web push notifications to your WordPress site. You may also want to see our guide to the best email marketing services, and how to get a free business email address for your website.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Add Web Push Notification to Your WordPress Site appeared first on WPBeginner.


October 13, 2020 at 06:10PM

Monday, October 12, 2020

How to Fix the Facebook and Instagram oEmbed Issue in WordPress

If you have ever embedded Facebook or Instagram content in WordPress using the default oEmbed or Embed blocks feature, then you need to implement this fix immediately.

Starting October 24th, you will no longer be able to automatically embed Facebook and Instagram content in WordPress using the default methods due to a breaking change in the Facebook API.

But don’t worry, in this article, we will show you how to fix the Facebook and Instagram embed issue in WordPress, so your content embeds keep working, and you never lose any features.

Fix Facebook and Instagram oEmbed Issue in WordPress

Why will the Facebook & Instagram Embeds Stop Working?

That’s because Facebook recently announced that all oEmbed requests for Facebook and Instagram content will be deprecated on October 24th, 2020.

This API is fundamental to both Gutenberg and the WordPress Classic editor’s default embed feature that lets you easily embed videos, pictures, updates, and other content from Facebook and Instagram.

Instead, Facebook now requires each developer to register an app, and use a client token when getting data from their Graph API for oEmbed content.

This is not scalable for WordPress core team to implement in the WordPress project, so a decision has been made to remove Facebook and Instagram embed feature from WordPress core in favor of letting WordPress plugins solve the issue for users (core ticket #50861).

So basically if you have any Facebook embeds in your WordPress content, then they will break and look like this after October 24th:

Facebook oEmbed Before and After

If you have any Instagram embeds in your WordPress content, they will break and look like this after October 24th:

Instagram oEmbed Before and After API Change

How to Fix the Facebook & Instagram oEmbed Issue (Restore Default Features)

The easiest and most beginner friendly way to fix the oEmbed issue is to use the Smash Balloon free Instagram Feed plugin, and custom Facebook Feed plugin. For more details, see our step by step guide on how to install a WordPress plugin.

These plugins are developed by our team at Awesome Motive, and they’re used by over 1.2 million users.

When we heard about this upcoming breaking change, we realized that we were in the best position to solve the problem for our users and the larger WordPress community.

Since Smash Balloon has to register an API key to create custom feeds for both Facebook and Instagram, we didn’t need any additional authentication to restore this functionality.

If you’re already using our Smash Balloon feed plugin, then you simply need to upgrade to the latest version, and the default oEmbed features will continue to work without any issues.

If you run into any troubles, or if you’re a new user who wants to restore the oEmbed functionality, then simply go to the oEmbed navigation menu under Smash Ballon’s Facebook / Instagram feed plugin, and then click on the Connect button.

SmashBalloon New oEmbed Features

The best part about using the Smash Balloon plugins is that you will NOT need to go through a complicated process of creating your own app.

We made the process easy for beginners, and as a bonus, you’ll now have all the powerful custom feed features of the Smash Ballon Instagram and Facebook feed plugins.

Alternate Method: Restore Default Facebook / Instagram oEmbed Features

If you’re a developer and would prefer to go through the complex process of registering a Facebook app for each client site to restore this functionality, then you can use the oEmbed Plus plugin.

It’s a new plugin created by one of the volunteer developers to restore the default oEmbed for Facebook and Instagram.

Act Fast and Spread the Word

There are only 12 days left before the Facebook and Instagram embeds in WordPress will stop working.

If you have ever embedded content from Facebook or Instagram on your site using the default embed features, then you need to act fast.

We strongly recommend that you install and activate the Smash Balloon free Instagram Feed plugin, and custom Facebook Feed plugin.

If you’re new in your WordPress journey and just started a blog, then we also recommend that you install the above plugins, so you have access to the easy embed blocks for Facebook and Instagram.

Last but not least, we need your help in spreading the word, so more people can fix this issue on their website before things start breaking. Please share this article in your network and help us spread the word.

We hope this article helped you learn how to fix the Facebook and Instagram oEmbed issue in WordPress. You may also want to see our expert pick of the must have WordPress plugins, and our guide on how to get a virtual business phone number app for your website.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Fix the Facebook and Instagram oEmbed Issue in WordPress appeared first on WPBeginner.


October 12, 2020 at 09:08PM

How to Create Custom Taxonomies in WordPress

Do you want to create custom taxonomies in WordPress?

By default, WordPress allows you to organize your content with categories and tags. But with custom taxonomies, you can further customize the way you sort your content.

In this article, we’ll show you how to easily create custom taxonomies in WordPress with or without using a plugin.

How to create custom taxonomies in WordPress

While creating custom taxonomies is powerful, there’s a lot to cover. To help you set this up properly, we have created an easy table of content below:

What is a WordPress Taxonomy?

A WordPress taxonomy is a way to organize groups of posts and custom post types. The word taxonomy comes from the biological classification method called Linnaean taxonomy.

By default, WordPress comes with two taxonomies called categories and tags. You can use them to organize your blog posts.

However, if you are using a custom post type, then categories and tags may not look suitable for all content types.

For instance, you can create a custom post type called ‘Books’ and sort it using a custom taxonomy called ‘topics’.

You can add topic terms like Adventure, Romance, Horror, and other book topics you want. This would allow you, and your readers to easily sort books by each topic.

Taxonomies can also be hierarchical, meaning that you can have main topics like Fiction and Nonfiction. Then you’d have subtopics under each category.

For example, Fiction would have Adventure, Romance, and Horror as sub-topics.

Now that you know what a custom taxonomy is, let’s learn how to create custom taxonomies in WordPress.

How to Create Custom Taxonomies in WordPress

We will use two methods to create custom taxonomies. First, we’ll use a plugin to create custom taxonomies.

For the second method, we’ll show you the code method, and how to use it to create your custom taxonomies without using a plugin.

Create Custom Taxonomies In WordPress (Video Tutorial)

If you prefer written instructions, then continue reading.

Creating Custom Taxonomies With A Plugin (The Easy Way)

First thing you need to do is install and activate the Custom Post Type UI plugin. For details, see our guide on how to install a WordPress plugin.

In this tutorial, we’ve already created a custom post type and called it ‘Books.’ So make sure you have a custom post type created before you begin creating your taxonomies.

Next, go to CPT UI » Add/Edit Taxonomies menu item in the WordPress admin area to create your first taxonomy.

Creatig custom taxonomy using plugin

On this screen, you will need to do the following:

  • Create your taxonomy slug (this will go in your URL)
  • Create the plural label
  • Create the singular label
  • Auto-populate labels

Your first step is to create a slug for the taxonomy. This slug is used in the URL and in WordPress search queries.

This can only contain letters and numbers, and it will automatically be converted to lowercase letters.

Next, you will fill in the plural and singular names for your custom taxonomy.

From there, you have the option to click on the link ‘Populate additional labels based on chosen labels’. If you do this, then the plugin will auto-fill in the rest of the label fields for you.

Now, scroll down to the ‘Additional Labels’ section. In this area, you can provide a description of your post type.

Labeling your WordPress taxonomy

These labels are used in your WordPress dashboard when you’re editing and managing content for that particular custom taxonomy.

Next up, we have the settings option. In this area, you can set up different attributes for each taxonomy you create. Each option has a description detailing what it does.

Create custom taxonomy hierarchy

In the screenshot above, you’ll see we chose to make this taxonomy hierarchical. This means our taxonomy ‘Subjects’ can have sub-topics. For instance, a subject called Fiction can have sub-topics like Fantasy, Thriller, Mystery, and more.

There are many other settings further down your screen in your WordPress dashboard, but you can leave them as-is for this tutorial.

You can now click on the ‘Add Taxonomy’ button at the bottom to save your custom taxonomy.

After that, go ahead and edit the post type associated with this taxonomy in the WordPress content editor to start using it.

Using taxonomy in post editor

Creating Custom Taxonomies Manually (with code)

This method requires you to add code to your WordPress website. If you have not done it before, then we recommend reading our guide on how to easily add code snippets in WordPress.

1. Creating a Hierarchical Taxonomy

Let’s start with a hierarchical taxonomy that works like categories and can have parent and child terms.

Add the following code in your theme’s functions.php file or in a site-specific plugin (recommended) to create a hierarchical custom taxonomy like categories:

//hook into the init action and call create_book_taxonomies when it fires

add_action( 'init', 'create_subjects_hierarchical_taxonomy', 0 );

//create a custom taxonomy name it subjects for your posts

function create_subjects_hierarchical_taxonomy() {

// Add new taxonomy, make it hierarchical like categories
//first do the translations part for GUI

  $labels = array(
    'name' => _x( 'Subjects', 'taxonomy general name' ),
    'singular_name' => _x( 'Subject', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Subjects' ),
    'all_items' => __( 'All Subjects' ),
    'parent_item' => __( 'Parent Subject' ),
    'parent_item_colon' => __( 'Parent Subject:' ),
    'edit_item' => __( 'Edit Subject' ), 
    'update_item' => __( 'Update Subject' ),
    'add_new_item' => __( 'Add New Subject' ),
    'new_item_name' => __( 'New Subject Name' ),
    'menu_name' => __( 'Subjects' ),
  );    

// Now register the taxonomy
  register_taxonomy('subjects',array('books'), array(
    'hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'show_in_rest' => true,
    'show_admin_column' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'subject' ),
  ));

}

Don’t forget to replace the taxonomy name and labels with your own taxonomy labels. You will also notice that this taxonomy is associated with the Books post type, you’ll need to change that to whatever post type you want to use it with.

2. Creating a Non-hierarchical Taxonomy

To create a non-hierarchical custom taxonomy like Tags, add this code in your theme’s functions.php or in a site-specific plugin:

//hook into the init action and call create_topics_nonhierarchical_taxonomy when it fires

add_action( 'init', 'create_topics_nonhierarchical_taxonomy', 0 );

function create_topics_nonhierarchical_taxonomy() {

// Labels part for the GUI

  $labels = array(
    'name' => _x( 'Topics', 'taxonomy general name' ),
    'singular_name' => _x( 'Topic', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Topics' ),
    'popular_items' => __( 'Popular Topics' ),
    'all_items' => __( 'All Topics' ),
    'parent_item' => null,
    'parent_item_colon' => null,
    'edit_item' => __( 'Edit Topic' ), 
    'update_item' => __( 'Update Topic' ),
    'add_new_item' => __( 'Add New Topic' ),
    'new_item_name' => __( 'New Topic Name' ),
    'separate_items_with_commas' => __( 'Separate topics with commas' ),
    'add_or_remove_items' => __( 'Add or remove topics' ),
    'choose_from_most_used' => __( 'Choose from the most used topics' ),
    'menu_name' => __( 'Topics' ),
  ); 

// Now register the non-hierarchical taxonomy like tag

  register_taxonomy('topics','books',array(
    'hierarchical' => false,
    'labels' => $labels,
    'show_ui' => true,
    'show_in_rest' => true,
    'show_admin_column' => true,
    'update_count_callback' => '_update_post_term_count',
    'query_var' => true,
    'rewrite' => array( 'slug' => 'topic' ),
  ));
}

Notice the difference between the 2 codes. Value for hierarchical argument is true for category-like taxonomy and false for tags-like taxonomies.

Also, in the labels array for non-hierarchical tags-like taxonomy, we have added null for parent_item and parent_item_colon arguments which means that nothing will be shown in the UI to create parent item.

Taxonomies in post editor

Displaying Custom Taxonomies

Now that we have created custom taxonomies and have added a few terms, your WordPress theme will still not display them.

In order to display them, you’ll need to add some code to your WordPress theme or child theme.

This code will need to be added in templates files where you want to display the terms.

Usually, it is single.php, content.php, or one of the files inside the template-parts folder in your WordPress theme. To figure out which file you need to edit, see our guide to WordPress template hierarchy for details.

You will need to add the following code where you want to display the terms.

<?php the_terms( $post->ID, 'topics', 'Topics: ', ', ', ' ' ); ?>

You can add it in other files as well such as archive.php, index.php, and anywhere else you want to display the taxonomy.

Custom Taxonomy Displayed

By default your custom taxonomies use the archive.php template to display posts. However, you can create a custom archive display for them by creating taxonomy-{taxonomy-slug}.php.

Adding Taxonomies For Custom Posts

Now that you know how to create custom taxonomies, let’s put them to use with an example.

We’re going to create a taxonomy and call it Non-fiction.

Since we have a custom post type named ‘Books,’ it’s similar to how you’d create a regular blog post.

In your WordPress dashboard, go to Books » Subjects to add a term or subject.

Adding a term for your newly created custom taxonomy

On this screen, you’ll see 4 areas:

  • Name
  • Slug
  • Parent
  • Description

In the name, you’ll write out the term you want to add. You can skip the slug part and provide a description for this particular term (optional).

Lastly, click the ‘Add New Subject’ button to create your new taxonomy.

Your newly added term will now appear in the right column.

Term added

Now you have a new term that you can use in your blog posts.

You can also add terms directly while editing or writing content under that particular post type.

Simply go to the Books » Add new page to create a post. On the post edit screen, you’ll find the option to select or create new terms from the right column.

Adding new terms or select from existing terms

After adding terms, you can go ahead and publish that content.

All your posts filed under that term will be accessible on your website on their own URL. For instance, posts filed under Fiction subject would appear at the following URL:

https://ift.tt/36YaPgk

Taxonomy template preview

Now that you have created custom taxonomies, you may want to display in your website’s navigation menu.

Go to Appearance » Menus and select the terms you want to add under your custom taxonomy tab.

Adding terms to navigation menu

Don’t forget to click on the Save Menu button to save your settings.

You can now visit your website to see your menu in action.

Adding custom taxonomy in navigation menu

For more detailed, see our step by step guide on how to create a dropdown menu in WordPress.

Take WordPress Taxonomies Further

There are a ton of things you can do with custom taxonomies. For instance, you can show them in a sidebar widget or add image icons for each term.

You can also add enable RSS feed for custom taxonomies in WordPress and allow users to subscribe individual terms.

If you want to customize the layout of your custom taxonomy pages, then you can check out Beaver Themer or Divi. They’re both drag and drop WordPress page builder that allows you to create custom layouts without any coding.

We hope this article helped you learn how to create custom taxonomies in WordPress. You may also want to see our guide on how WordPress works behind the scenes, and how to create a custom WordPress theme without writing any code.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Create Custom Taxonomies in WordPress appeared first on WPBeginner.


October 12, 2020 at 06:00PM