Beginner’s Guide to Pasting Snippets from the Web into WordPress

Do you want to learn how to paste snippets from the web into WordPress?

We publish a lot of WordPress tutorials that ask users to add code snippets to WordPress.

Copying and pasting code in WordPress theme files might seem easy for experienced users, but it can be intimidating for beginners.

In this article, we’ll show you how to copy and paste code snippets from the web into WordPress without breaking your site.

Beginner's guide to pasting snippets from the web into WordPress

Why Add Code Snippets to Your WordPress Site?

WordPress is the best website builder in the world due to the flexibility it offers. It’s super easy to add new features and functionality to your site and can help build nearly any type of website.

We share all kinds of tips and tricks you can use to make your website better. Some of these tips will ask you to add code to WordPress.

While adding custom code snippets to your website is optional, and you can often find plugins to do the same task, sometimes a simple snippet is more efficient.

Often, adding code snippets can be an easy way to fix many common WordPress errors, improve your WordPress security, and add new features to your website.

With that said, let’s take a look at how to add code snippets to your WordPress website safely.

What are the Best Ways to Add Code Snippets in WordPress?

It’s important to mention that before you start adding code snippets to your WordPress website, you should install and use a WordPress backup plugin.

This keeps your WordPress site safe, and you can always restore it from a backup in case anything goes wrong.

When adding snippets to WordPress, you may find instructions to add them to WordPress theme template files, like index.php, single.php, and more.

These snippets are only useful for those specific theme files, so you will have to add them directly or create a WordPress child theme.

However, most code snippets will be added to your WordPress theme’s functions.php file. Some tutorials might recommend adding it directly to the file, but there are much better alternatives that allow you to future-proof your changes.

This way if you ever change a theme, your custom functionality will not be removed.

There are different ways to edit WordPress files depending on which method you choose to add custom code snippets to your WordPress blog or website.

With that said, let’s take a look at some of the most beginner-friendly ways to add custom code snippets in WordPress.

Method 1: Adding Custom Code with the WPCode Plugin (Easy)

Using a code snippets plugin is the safest and most beginner-friendly way to add code to WordPress.

WPCode code snippets plugin

The WPCode plugin lets you add and manage custom code snippets on your website easily, without having to edit your theme files.

It comes with smart code snippet validation to help you prevent common code errors. This protects you from breaking your website when adding code snippets.

WPCode also has a built-in code library that makes it easy to find all of the most popular WordPress code snippets. You can add these expert-written code snippets in just a few clicks.

The best part is that it lets you manage all code snippets from one central screen, and you can even organize them using tags.

Note: The WPCode method is useful for snippets that need to be added to the functions.php file. If you are asked to add a code snippet in other theme files, then this method will not work.

How to Edit and Add Code to WordPress with WPCode

If you’re going to use the WPCode plugin to add code to WordPress, then you’ll be adding code directly in your WordPress admin dashboard.

First, you need to install and activate the plugin. For more details, see our beginner’s guide on how to install a WordPress plugin.

Upon activation, simply go to Code Snippets » + Add Snippet in your WordPress admin dashboard. Then, click the Add New button.

Click 'Add New Snippet' in WPCode

This brings you to a screen where you can choose a snippet from the pre-made library or add your custom code.

To add custom code, click on the Use snippet button under the ‘Add Your Custom Code (New Snippet)’ option.

Add custom code in WPCode

On the next screen, start by giving your snippet a name to help you remember it. Then, paste your code into the box. Be sure to choose the correct code type from the drop-down menu on the right.

Paste custom snippet and choose code type

Next, scroll down to the ‘Insertion’ section. Here you can choose to use the code snippet as a shortcode that you can manually copy and paste anywhere on your site. Or, select the ‘Auto Insert’ method to choose a location (WordPress function) where the code snippet will be automatically inserted.

Choose insertion option for code snippet

The best part about WPCode is that aside from the various Auto-Insert options, it also comes with beginner-friendly conditional logic option. This lets you select when your code should load.

WPCode Smart Conditional Logic

Once you’re done adding the code, toggle the switch from ‘Inactive’ to ‘Active’ in the top right corner.

Then click the Save Snippet button.

Save and activate code snippet

Once the snippet is active, it will be added automatically or displayed as shortcode, depending on the insertion method you chose.

For detailed instructions, see our guide on how to easily add custom code snippets in WordPress.

How to Add Code to the WordPress Header and Footer

Sometimes you may only need to add code to your theme’s header.php or footer.php files. The WPCode plugin can also help you do this easily.

This comes in handy when you need to add a tracking code for Google Analytics, Facebook Pixel, Google AdSense, and more to your website.

Plus, it lets you manage all of your header and footer codes in one place, prevents any manual errors, and lets you upgrade or change your theme without worries.

Note: This method works best for tracking scripts, custom CSS, and Javascript code.

Go to Code Snippets » Header and Footer and then enter your code snippet into the header, body, or footer, section of your website.

Add code to header and footer with WPCode

Make sure you click the ‘Save Changes’ button, and your code snippets will be live on your website.

For more details, see our guide on how to add header and footer code in WordPress.

Method 2: Adding Custom Code in Site-Specific WordPress Plugin

Create site specific plugin

Another flexible option is to use a site-specific WordPress plugin. This is a custom plugin that you can create for your own website and use to save all your custom code.

The advantage of this method is that your code is not dependent on your theme, and it will remain active even when you change themes. It is also not affected by any WordPress updates on your website.

Note: This method is only applicable for code snippets that need to be added to the functions.php file.

If you’re using a site-specific plugin, then you can use the built-in WordPress plugin editor to add your custom code.

First, you’ll need to go to Plugins » Plugin Editor and then select your plugin from the drop-down menu labeled ‘Select plugin to edit:’.

The editor will load your site-specific plugin. Then, you can simply add code to the page.

Add code to site specific plugin

Once you’re finished, make sure to click on the ‘Update File’ button to save your changes.

If something is missing in your code or can break your website, then the plugin editor will automatically undo your changes.

Another way you can add custom code to a site-specific plugin is by using FTP. For more details, see our beginner’s guide on how to use FTP to upload files to WordPress.

Simply open up your website using your preferred FTP client, and then right-click on the plugin file and select the ‘View/Edit’ option.

Edit site-specific WordPress plugin using FTP

This will open up the file so that you can add your code snippets. When you save and upload the file again, then changes will automatically show up.

For more details, see our guide on how to create a site-specific plugin for your website.

Method 3: Adding Custom Code to Functions.php or Other Theme Templates

Add code to functions.php example

Finally, it is okay to add code snippets directly to your theme’s functions.php file. However, we recommend using the other options above, since there are some downsides.

First, if you update your WordPress theme, then all of your changes will be gone.

Next, the code you added will only work if you are using that particular theme.

That being said, let’s take a look at how to properly copy and paste code snippets and avoid breaking your website.

If you are adding code snippets directly to your theme’s functions.php file or any other page template, then you can add the code by navigating to Appearance » Theme Editor in your WordPress admin panel.

Then, you can select the file from the right-hand column, and it will open up in the editor.

Add code to functions.php and other templates

The tutorial you’re following will tell you where you can add the code snippet, but if not, then you need to add the code at the bottom of the file beneath all the code that’s present.

Another alternative is to use FTP of your WordPress hosting file manager to add custom code to your theme files.

Simply connect to your FTP client to your website and then go to wp-content » themes » your-theme-folder and right-click on the file that needs editing.

Edit theme files via FTP

Then, click the ‘View/Edit’ option to open the file in the text editor and add your code snippet.

Troubleshooting PHP Errors when Adding Custom Code

There are some common mistakes that beginners make when adding custom code snippets to their WordPress websites. Luckily, most of these errors can be avoided and fixed easily.

Let’s take a look at these errors and the best ways you can fix them.

1. Incorrect Usage of PHP Begin and End Tags

WordPress is written mainly in the PHP programming language which has a specific syntax that tells your server that the following code needs to be processed by PHP. Here is what a typical PHP code snippet looks like:

 // PHP Begin Tag <?php  // Rest of the code goes here  // PHP End Tag ?> 

All your PHP code needs to be inside the <?php and ?> tags.

The PHP end tag is very important in files that switch back and forth between PHP and HTML. This includes most WordPress theme files that use PHP tags alongside HTML.

You need to make sure that if you are pasting your code at a location where the PHP start tag is not closed, then you need to add your code without the starting PHP tag.

 <?php // Some pre-existing code  // your custom code  ?> 

If you are pasting your custom code outside or after the PHP end tag, then you need to add the PHP begin tag as well.

 <?php // Some pre-existing code ?>   // Your custom code snippet <?php   ?> 

Almost 90% of all errors are caused by the incorrect placement of PHP start or end tags. Looking at your code will help you understand whether or not you need to add the PHP start or end tags in your custom code snippet.

However, many WordPress theme files like functions.php may not have a PHP end tag at all. This means that you can add your code at the bottom of the file without the start or end tags.

Here’s an example of what that looks like.

 <?php // Lots of code in your theme's functions.php file // // // Your custom code function custom_loginlogo() { echo '<style type="text/css"> h1 a {background-image: url('.get_bloginfo('template_directory').'https://cdn.wpbeginner.com/images/login_logo.png) !important; } </style>'; } add_action('login_head', 'custom_loginlogo'); 

Remember that some tutorials may assume that you already know how to use PHP start and end tags. So, they may simply show you a code snippet without those tags in place.

 function custom_loginlogo() { echo '<style type="text/css"> h1 a {background-image: url('.get_bloginfo('template_directory').'https://cdn.wpbeginner.com/images/login_logo.png) !important; } </style>'; } add_action('login_head', 'custom_loginlogo'); 

Sometimes when code snippets are given they can be added to multiple locations, so the PHP end and start tags won’t be included.

When you are adding such a code snippet in your theme files, you need to make sure that it is inside the PHP tags.

2. Incorrect Nesting Errors

PHP has a particular syntax for functions, conditional logic, and loops. This syntax depends on curly brackets which indicate when a function begins and when it ends.

For example, here is a simple PHP function:

 <?php function wpbeginner_tutorial() { echo "Hello World!"; } ?> 

Now if you want to add a custom code snippet that has nothing to do with this function, then you will need to put it outside this function like this:

 // Pre-existing code in your theme file <?php function wpbeginner_tutorial() { echo "Hello World!"; } // Your custom code function custom_loginlogo() { echo '<style type="text/css"> h1 a {background-image: url('.get_bloginfo('template_directory').'https://cdn.wpbeginner.com/images/login_logo.png) !important; } </style>'; } ?> 

If you miss the starting or ending curly brackets, then this will break the code, and you will end up with an error page.

Understanding PHP Errors in WordPress

Errors that are caused by adding custom code to WordPress will often result in a detailed error message. Most of them are syntax errors, parse errors, or fatal errors due to unexpected characters.

The good news is that these errors will tell you which line in your code caused the error.

PHP error code example

Then, you can then go to the exact line to review the code and figure out what you missed.

For this, we recommend using a proper text editor for code editing because they have line numbers and syntax highlighting which can help you fix the issue easily.

What to do When Your WordPress Site is Inaccessible?

First of all, take a deep breath and don’t panic. All of your website’s files are still there and you can access them.

Simply connect to your website using an FTP client or the file manager app in cPanel in your WordPress hosting account.

For more details, see our beginner’s guide on how to use FTP to upload files to WordPress.

Next, locate the file where you added the code that caused the error and open it to edit it.

Then, you can try and fix the issues with the code snippet. If you are unable to fix those issues, then simply remove the code snippet you added and save your changes.

Now, your site should be back to normal again. If it is still showing some error, then download a fresh copy of your WordPress theme and extract the zip file to your computer.

After that, locate the file where you made the changes earlier, and upload it to your server while overwriting the old file.

For more ways to solve these issues, see our guide on the most common WordPress errors and how to fix them. If that doesn’t help, then follow our WordPress troubleshooting guide to perform a step by step diagnosis.

We hope this article helped you learn how to paste code snippets from the web into WordPress. You may also want to see our guide on how to create a free business email address and our picks of the best live chat software for small businesses.

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.

Beginner’s Guide on How to Moderate Comments in WordPress

Do you want moderate comments on your WordPress site but don’t know where to get started?

WordPress comes with a built-in comment system that allows for community interaction around your content.

In this beginner’s guide, we will show you how to moderate comments in WordPress, deal with comment spam, and everything related to comments.

How to Moderate Comments in WordPress

What Are Comments in WordPress?

Comments allow your website visitors to communicate with you and other readers. They can add their input on a specific article that you had written, ask questions, and provide feedback.

On most WordPress sites, anyone with a valid name and email can leave a comment without verifying their identity.

By default, comments are turned on. There will be a comment form displayed at the bottom of any blog post or page, though it may look different or not appear depending on the WordPress theme you’re using.

Comment form in WordPress

Once someone submits a comment, they will see a preview of their comment and a message saying that the comment is awaiting moderation.

Before the comment appears for other visitors, it will be held for moderation for you to approve or delete. This allows you to control what appears on your website.

Comment moderation message

That said, let’s look at how you can moderate comments on your website.

Moderating Comments in WordPress

You can see all comments on your WordPress website by clicking on the ‘Comments’ menu in the WordPress dashboard.

Comments section in WordPress

On the comments page, you will see 5 different tabs, including all comments, mine, pending, approved, spam and trash. Comments that need your approval will appear under the Pending tab.

To approve a comment, take your mouse over to the comment, and you will see action links appear below it. Click on the ‘Approve’ button to make a comment publicly visible on your website.

You can also reply to a comment by clicking on the reply link. Replying to comment automatically approves the comment as well.

If you see a comment that looks or feels spammy, then you can mark it as Spam. You’re probably wondering, what does a spam comment look like?

Well, there are a few different indicators that you can use to tell if a comment is a spam:

  • Comments with a bunch of links, keywords, and strange characters – This is the most obvious type of spam comment. They could also contain inappropriate content in the comment.
  • Comment with a Fake Name – If you see a comment that’s being left by a person named “Best Mortgage Rates” or “Cheap Printer Ink”, then you can clearly tell it’s a marketer trying to spam your site for a backlink.
  • Generic Comments – Often spammers rely on generic comments to bypass your spam filter. These generic comments are “Thank You”, “Really Nice Article”, or insert the title of your post and make a generic statement (example: I agree beginners guide to comment moderation is essential).

Filter Spam Comments using Akismet

To filter spam comments from your WordPress website, you can use Akismet. It’s a spam filtering WordPress plugin and is developed by Automattic.

Once you mark a comment as spam, Akismet will learn to catch similar comments in the future.

Edit Akismet settings

For more details, you check out our guide on what is Akismet and why you should use it.

All comments marked as spam will appear under the spam tab. You will not need to visit this tab that often. However, if a user complains that their comments are not appearing on your website, then this is the first place you should look.

If you find a comment that is wrongly caught by Akismet as spam, then simply click on the ‘Not Spam’ link to move it from spam to pending.

Click not spam button

You can also click on the ‘Empty Spam’ button to delete all spam comments at once. Even if you don’t, spam comments will be automatically deleted by WordPress after 15 days.

Remember that deleting thousands of spam comments at once can slow down your site a bit. If you are trying to delete thousands of spam comments, then you can perform a bulk action. You can check out our guide on how to quickly batch delete spam comments in WordPress.

If for some reason you accidentally got hundreds of spam comments appearing in the ‘Pending’ tab, then simply click on the ‘Check for spam’ button.

This will trigger a spam check on existing comments on your website, and Akismet will move spam comments from Pending to Spam.

Check for spam button

If you want to remove a comment without marking it as spam, then simply click on the ‘Trash’ link below the comment.

Comments deleted by you will be sent to the trash and will live there for the next 30 days. After this time, WordPress will automatically delete them forever.

If you accidentally deleted a comment, then simply visit the trash tab and click on the ‘Restore’ link below the comment.

Restore comment from trash

The comment moderation area shows comments for all posts and pages. However, you can individually view the comments left on a particular post by either visiting that post on your site or through your admin area.

Turn Comments On/Off for Specific Posts in WordPress

There are some times when you don’t want comments to be enabled on certain posts. WordPress allows you to turn comments off for single posts or pages.

Simply edit a post and on the WordPress editor screen, open the ‘Discussion’ box from the settings menu on your right. Next, you can uncheck the box for the ‘Allow comments’ option.

Allow comments in discussion box

You can also go to Posts » All Posts from your WordPress dashboard and click the ‘Quick Edit’ button for any blog post. After that, simply uncheck the ‘Allow Comments’ option.

Allow comments in WordPress

Allow Blog Users to Moderate Comments in WordPress

If you have lots of articles and get many comments every day, then it can be a challenge to moderate all the WordPress comments.

A simple solution to this issue is having a dedicated comment moderator on your website. You can assign a separate comment moderator role to a user that’s an active commenter on your site or a member of your customer support team.

WordPress doesn’t offer a user role that’s dedicated to moderation comments. However, you can use the Comment Moderation Role plugin.

The plugin is created by our team at WPBeginner, and it allows you to give users access to only see the comment moderation screen in WordPress. You can assign the role to existing and new users.

Change user role to comment moderator

For more details, please see our guide on how to allow blog users to moderate comments in WordPress.

Comment Settings Configuration

Finally, WordPress allows you to change comment configuration for your entire site.

The comments settings page is located under Settings » Discussion. There are different sections on the discussion settings page, and we will walk you through each option on the page.

Discussion settings

Default post settings

The top section on the discussion settings screen controls the Default post settings.

The first option in this section allows your blog to notify other blogs when you link to them in an article. The second option allows similar notifications from other blogs to be accepted on your site.

These are called pingbacks and trackbacks, and we recommend you to uncheck both these options. The first option can slow down your entire site, and the second option would bring you a lot of spam comments.

The third option on the article settings screen is ‘Allow people to post comments on new posts,’ enabling comments for all new articles you write on your WordPress site. It is important to note that you can turn comments on and off for individual articles like we showed you earlier in this article.

Other comment settings

Under the other comment settings section, you will notice the first option as ‘Comment author must fill out name and email.’ This option makes it mandatory for comment authors to provide a name and email address with their comments.

You need to check this option unless you want to allow anonymous commenting on your website.

Other comment settings

There is also an option to require users to register to your site before leaving a comment however, in our opinion, it’s not necessary for most sites.

You will also see the option for closing comments on older articles. Some website owners use this to prevent spam, but it’s completely a personal preference.

WordPress allows users to reply to comments. Those replies will appear nested under the original comment only if you check the box next to ‘Enable threaded (nested) comments’ and you can specify how deep these nested comments can go.

Having too many levels can distort the readability of comments. The default setting of 5 levels is good enough for most WordPress themes.

If one of your articles becomes popular and starts getting too many comments, then you will notice that the comment section will become too long. Users will have to scroll a lot to read the latest comments on the article.

To address this problem, you can check the option to break comments into pages. By default, this option allows 50 top-level comments, you can increase or decrease this. Choosing this option will also show the last page of comments first.

Another option is to show your most recent comments first.

Email me whenever and Before a comment appears settings

Email me whenever setting

The next section allows you to receive emails whenever a user leaves comments on your site or whenever a comment is held for moderation. This option is only exciting for the first few days of your website. As you get more comments, these emails become annoying, so we recommend turning them off.

Under the ‘Before a comment appear’ section, the first option is to approve each comment manually. Make sure this box is checked so that no comment can appear on your site without your approval.

Below this, you will see the ‘Comment author must have a previously approved comment’ option.

If this option is checked, comments from authors with a previously approved comment will appear without explicit approval. Simply uncheck this option to make sure that all comments are manually approved.

Comment Moderation settings

Comment moderation setting

A very common trait among automated spam comments is that they contain a lot of links. Since you have already set your comments to be manually approved, all your comments will go to the moderation queue regardless of how many links they have.

You will see a larger text area where you can enter words, IP and email addresses, or URLs that you want to watch out for. Any comment matching things you enter here will be sent to the moderation queue.

There is no need for you to enter anything here since you have already set all comments to be manually approved, and they are all going to the moderation queue anyways.

Avatars settings

Avatars settings

The last section on the comments settings screen is for Avatars. These are the images that appear next to the comment author’s name on your website.

WordPress uses Gravatar, which is a free service that allows users to have the same avatar on all the blogs they visit (see our guide on what is Gravatar).

WordPress uses Mystery Person as the default gravatar when a comment author doesn’t have a Gravatar image associated with their email address. You can change this by selecting a default avatar from the list or even add your own custom default gravatar in WordPress.

That’s all! You have configured your comment settings. Don’t forget to click on the Save Changes button to store your settings.

We hope this article helped you learn how to moderate comments in WordPress. You may also want to check out our guide on how to start an online store and best WooCommerce plugins.

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.

Beginner’s Guide to Creating 301 Redirects in WordPress (Step by Step)

Do you want to create 301 redirects on your WordPress website?

When someone visits your site using an old link to a page that has moved, a 301 redirect will automatically take them to the new page so they do not see a 404 ‘page not found’ error. This provides a better user experience and will also improve your keyword rankings.

In this article, we’ll show you how to create 301 redirects in WordPress.

Beginner’s Guide to Creating 301 Redirects in WordPress

What Is a Redirect in WordPress?

A redirect is a way for your WordPress website to automatically send users to a new address when the page they wish to visit has been moved or replaced. This is similar to the way a post office will redirect your mail when you move house.

There are various types of redirects that are identified with numbers such as 301, 302, and 307. They automatically point your user’s web browser to a different URL when trying to visit a page that doesn’t exist.

In this beginner’s guide, we will focus on 301 redirects since they are the most important type. They tell the browser that the page has been permanently moved to the new location and that you don’t intend to move it back.

That said, let’s take a look at when you should use a 301 redirect.

When Do You Need a 301 Redirect in WordPress?

The primary reason to use a 301 redirect is when your site or a page on your site has been moved, and you want to point the user to a new page instead.

It is also needed when you plan on changing the permalink of a post or page.

If you don’t set up redirection, then it will cause your users to see a 404 error when the page is not found. This provides a bad user experience and can impact your WordPress SEO.

404 Page Example

You can also lose valuable backlinks if there are a lot of broken links on your site. This will result in a significant drop in your domain authority and keyword rankings.

That’s why 301 redirects are very important. They allow you to tell search engines and your users that the page they are trying to reach has been permanently moved to a new location.

This way, all your old page’s traffic and backlinks are transferred to the new page.

Now, let’s take a look at how you can create 301 redirects in WordPress. We’ll show you how to do that easily with several WordPress redirect plugins, and manually using code.

Video Tutorial

Subscribe to WPBeginner

If you’d prefer written instructions, just keep reading.

Method 1: Creating 301 Redirects With AIOSEO Plugin

The simplest way to manage and create 301 redirects is through the All in One SEO (AIOSEO) WordPress plugin. It’s the best SEO plugin for WordPress and is used by over 2 million professionals to improve their site’s SEO.

AIOSEO offers a powerful redirection manager addon that makes it very easy to find broken links on your website and set up 301 redirections to fix them.

Note: You’ll need AIOSEO Pro to use the redirection manager. There is also a free version of AIOSEO, but it doesn’t include 301 redirects.

First, you need to install and configure the AIOSEO Pro plugin on your website. For more information, please refer to our step-by-step guide on how to set up All in One SEO correctly.

Once the plugin is active, you’ll need to go to All in One SEO » Redirects on your WordPress dashboard and then click the ‘Activate Redirects’ button.

Activate AIOSEO Redirects

Next, you can click the ‘Settings’ tab and select ‘PHP’ as the Redirect Method.

This is the simplest method for creating redirects and doesn’t require any server-side configuration.

Select the Redirect Method

AIOSEO also lets you select the Web Server redirect method. However, it requires configuring Apache or NGINX on your web server. This requires technical knowledge and is not recommended for beginners.

Creating 301 Redirects

Now you’re ready to create 301 redirections. To get started, head over to the ‘Redirect’ tab.

First, you need to enter the link you’d like to redirect in the Source URL field. After that, you should enter the new destination for the link in the Target URL field.

Enter Source URL and Target URL

Now make sure that the Redirect Type is ‘301 Moved Permanently,’ and then click the ‘Add Redirect’ button.

If you want to redirect multiple URLs to a new location, then simply click the ‘Add URL’ button under the Source URLs field.

Next, you can scroll down to view the logs of the redirects you’ve created. It shows the number of people who visited the redirected link under the ‘Hits’ column and a toggle option to enable or disable individual 301 redirects.

View Redirect Logs in AIOSEO

Adding 301 Redirects to Fix 404 Errors

AIOSEO can also help you track 404 error pages and fix them.

To turn this option on, you have to scroll down to the ‘Redirect Logs’ section of the Settings tab. Then enable the options for ‘404 Logs’ and ‘Redirect Logs.’

You can also select the time period to keep the logs. We recommend keeping them for a maximum of one month for smooth and fast server performance.

Enable 404 Logs

After enabling these options, make sure to click the ‘Save Changes’ button.

You should now see a new ‘404 Logs’ tab appear in the Redirects section. This is where AIOSEO will track and show your broken links and allow you to set up redirections. You’ll also see the number of visits to the link under ‘Hits’ and the last accessed date and time.

404 Logs Under Redirects

Note: You won’t find any data when you first enable the 404 logs. The plugin only starts to record 404 error pages after the setting is enabled.

Next, click the ‘Add Redirect’ link next to 404 error URL you’d like to redirect. This is not the button at the bottom.

You’ll now see options to enter a Target URL and select the Redirect Type from the dropdown menu.

Redirecting a 404 Error Using AIOSEO

Go ahead and enter your new URL and choose ‘301 Moved Permanently’ as your redirection type. Now you should click the ‘Add Redirect’ button.

AIOSEO will now create a 301 redirect for your broken link. To see if the redirection is working properly, simply visit the old URL to check if you’re taken to the new target destination.

Adding 301 Redirects Directly From a Post or Page

AIOSEO also lets you redirect a published post or page while you are editing it.

If you scroll to the bottom of the page in the WordPress editor, you will find an AIOSEO Settings section. You need to click on the ‘Redirects’ tab.

Redirect a Post From the WordPress Editor

The source URL has been filled in for you. Simply enter the new URL in the ‘Target URL’ field, and select ‘301 Moved Permanently’ from the Redirect Type drop down menu.

Also, if you change the permalink of a post while editing, AIOSEO will offer to redirect the old URL to the new one.

Either way, click the ‘Add Redirect’ button and you’re done.

Redirecting Full Websites

If you move your website to a new domain name, then your visitors may encounter broken links and your site SEO may suffer.

You can use AIOSEO to move your entire website to a new location without losing traffic or search engine rankings. This is a full site 301 redirect.

AIOSEO Full Site Redirect

It’s important that you do this the right way, so we have created a step-by-step beginner’s guide on how to do a full site redirect with WordPress.

Method 2: Creating 301 Redirects With Redirection Plugin

Another way to add and manage redirects in WordPress is with the Redirection plugin.

First, you need to install and activate the plugin. You can follow our detailed guide on how to install a WordPress plugin.

Note: While setting up 301 redirects using a WordPress plugin is easy, it has some minor performance setbacks. Depending on your WordPress hosting provider, your redirects may be a few microseconds slower than other methods.

If you want to make your redirects as fast as possible, then you can do so by editing your .htaccess file using Method 5 below.

Once activated, visit Tools » Redirection and then click the ‘Start Setup’ button.

 Start Setup of Redirection Plugin

Next, you can select options to monitor permalink changes in WordPress and keep a log of all your redirects and 404 errors.

You can simply enable these options and click the ‘Continue Setup’ button.

Basic Setup Redirection Plugin

The plugin will now automatically test the Rest API.

When the status comes back as Good, go ahead and click the ‘Finish Setup’ button.

Rest API Test in Redirection

The redirection plugin will perform a few more tasks to complete its setup. When the progress bar reaches 100% you can click the ‘Continue’ button and then the ‘Ready to Begin’ button.

The plugin is now ready for you to create your 301 redirects. To get started, navigate to the Tools » Redirection section of your WordPress panel. You should look at the ‘Add new redirection’ section at the bottom of the screen.

Add a New Redirection at the Bottom of the Screen

You’ll see the basic settings to add a redirection. However, if you click the gear icon, you’ll see more options to choose your redirection type.

Simply enter the Source URL of your old page and add the ‘Target URL’ you want to redirect to. You should also make sure the HTTP code option is set to ‘301 – Moved Permanently.’

Add New Redirection to Your Website

Once you’ve entered all the details, go ahead and click the ‘Add Redirect’ button.

Method 3: Creating 301 Redirects With Simple 301 Redirects Plugin

One of the easiest ways to create 301 redirects is with the Simple 301 Redirects plugin. As the name suggests, it makes 301 redirects really simple.

To start, you’ll have to install and activate the plugin on your website.

After that, you need to visit Settings » 301 Redirects. Here you can enter the old URL in the ‘Request’ field and your target URL in the ‘Destination’ field.

Simple 301 Redirects

Once you’ve done that, click the ‘Add New’ button to create the 301 redirect. That’s it.

Simple 301 Redirects will begin working immediately.

Sometimes you may want to keep a post in your site’s feed or a page listed a certain way on your site, but have the content hosted elsewhere. This is where the Page Links To plugin comes in handy.

Once you install and activate the plugin, it adds a meta box to your WordPress editor. Here you can enter the address of the new location where you want to send your users.

Page Links To in WordPress Editor

When you press ‘Update’ or ‘Publish,’ WordPress will treat the post or page as normal, but when someone visits it, they will instead be redirected to the custom URL you chose.

For example, you might have a blog where you occasionally create downloadable content, but you want users on your online store site to see certain posts as products. You can use this plugin to do that without risking duplicate content penalties from Google or splitting your user base.

Method 5: Creating 301 Redirects Manually Using .htaccess

WordPress users can also set up 301 redirects by editing the .htaccess web server configuration file.

Please keep in mind that a small mistake in your .htaccess code can make your WordPress site inaccessible, and it may start showing the Internal Server Error.

That’s why it is important that you back up your .htaccess file before making any changes.

Edit Your .htaccess File Using the All in One SEO Plugin

If you have the All in One SEO plugin installed, then it offers an easy way to edit your .htaccess file.

Note: You will need All in One SEO Pro to use the .htaccess editor.

Simply visit the All in One SEO » Tools page and switch to the .htaccess Editor tab.

Editing .htaccess File Using All in One SEO

From here, you’ll see the contents of your .htaccess file in the editor. You can simply place any redirect code that you want to add at the bottom, after the ‘# END WordPress’ line.

Here is a simple redirect where we are trying to send a user visiting an old post to a new post.

 RewriteEngine On Redirect 301 /a-very-old-post/ http://yoursite.com/a-very-new-post/ 

Don’t forget to change the old post and new post URLs. When you’re done, click the ‘Save Changes’ button to store your settings and All in One SEO will update your .htaccess file.

Directly Edit Your WordPress .htaccess file

You can also edit your WordPress .htaccess file directly to set up any redirects.

To edit your .htaccess file, you’ll need to connect to your website using an FTP client. The .htaccess file resides in your WordPress site’s root directory.

If you can’t see your .htaccess file, then see our guide on why you can’t find .htaccess file on your WordPress site.

You can download .htaccess to your computer and edit it using a text editor like Notepad.

You can use this redirect code below to send a user visiting an old post to a new post. You should paste the code at the end of your .htaccess file, after the ‘# END WordPress’ line.

 RewriteEngine On Redirect 301 /a-very-old-post/ http://yoursite.com/a-very-new-post/ 

Make sure you change the old post and new post URLs. After that, you can save your changes and upload the .htaccess file back to the server.

Now you can test your redirect to make sure it is redirecting properly as you intended.

Edit .htaccess File

In addition, you can also access and edit your .htaccess file through your hosting provider’s dashboard and built-in file manager.

For example, you can find your .htaccess in SiteGround‘s file manager by going to Site Tools » Site » File Manager and navigating to your site’s /public_html/ folder.

SiteGround File Manager in Site Tools

Then, you can right-click the .htaccess file and select ‘Edit.’

Just add the 301 redirect code directly and save the file. Again, be sure to download the original .htaccess file for backup to be safe.

Editing your htaccess using SiteGround's file manager

We hope this beginner’s guide to creating WordPress redirects helped you set up redirects on your site. You may also want to check out our guide on how to start a WordPress blog the right way, or see our list of the best email marketing services for small business.

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.

Beginner’s Guide: How to Use WordPress Block Patterns

Do you want to learn how to use WordPress block patterns on your website?

Block patterns allow you to quickly add commonly used design elements to your post or page layouts.

In this article, we’ll show you how to use WordPress block patterns and find more patterns to use on your website.

Using block patterns in WordPress

Here are the topics we’ll cover in this guide.

What are WordPress Block Patterns?

WordPress block patterns are a collection of pre-made design elements that you can use for creating custom content layouts faster.

WordPress comes with an intuitive editor commonly known as the block editor. It allows users to create beautiful layouts for their posts and pages using blocks for common content elements.

WordPress block editor

However, not all WordPress users are designers or want to spend time creating layouts each time they need to create a post or page.

Block patterns provide an easy solution to that problem. WordPress now comes with a bunch of useful block patterns by default.

Block patterns in WordPress

Popular WordPress themes also provide their own patterns that you can use when writing content.

These patterns include items like pre-built multi-column layouts, media and text patterns, call-to-action patterns, headers, buttons, and more.

You can find even more patterns on the WordPress.org website, and you can even create and share your own patterns as well.

That being said, let’s take a look at how to easily use block patterns in WordPress to create beautiful content for your website.

How to Use Block Patterns in WordPress

By default, WordPress comes with a bunch of useful block patterns that you can use on your website. Your WordPress theme and some plugins may also add their own patterns.

To use block patterns, you need to edit the WordPress post or page where you want to use the block pattern.

On the post edit screen, click on the Add Block button to open the block inserter. From here, switch to the Patterns tab to view available block patterns.

Add block pattern

You can scroll down to see available block patterns.

You can also view block patterns in different categories like featured, buttons, columns, header, and more.

Sort block patterns by category

Alternatively, you can also click on the Explore button to view block patterns.

Here you can see larger previews in a popup.

Block patterns preview

Once you find a pattern you want to try, you can simply click to insert it to the content area of your post or page.

Edit block pattern

After that, you can simply point and click on any block inside the pattern to edit and change its contents to your own requirements.

You’ll still have all the options you normally have for each block. For instance, if it is a cover block, then you can change the cover color or background image.

You can add as many patterns as you need for your blog post or page. You can also simply delete a pattern to remove it from a post or page like you would delete any WordPress block.

Remove cover block

By using block patterns, you can quickly make beautiful layouts for your articles and WordPress site.

Ultimately, block patterns help save you time that you would otherwise spend on manually arranging blocks each time you need to add a header, gallery, buttons, and more.

Finding More Block Patterns to Use on Your Website

By default, WordPress comes with a few commonly used block patterns. WordPress themes may also add their own patterns to your website.

However, you can find a lot more block patterns than the ones available under the block inserter on your website.

Simply go to the WordPress Patterns Directory website to view many more block patterns.

Block pattern directory

Here you’ll find many more block patterns submitted by the WordPress community.

To use one of these block patterns, simply take your mouse over to the block pattern and click on the Copy button.

Copy block pattern

Next, you need to go back to your WordPress blog and edit the post or page where you want to insert this block pattern.

On the post edit screen, simply right-click and select Paste in the browser menu or press CTRL+V (Command + V on Mac).

Paste block pattern

How to Create and Share Your Own Block Patterns

Want to create and share your own WordPress block patterns and share them with the world?

WordPress makes it super easy to create block patterns and use them on your own websites or share them with all WordPress users across the globe.

Simply visit the WordPress Pattern Directory website and click on the ‘Create New Pattern’ link.

Create block pattern

Note: You’ll need to sign in or create a free WordPress.org account to save your patterns.

Once signed in, you’ll reach the block pattern editor page. It is identical to the default WordPress block editor, and you can use it to create your pattern.

Block pattern creator

Simply add blocks to create your pattern layout.

You can use layout blocks like group, cover, gallery, and more to organize your layout.

Editing block pattern layout

There are also royalty-free images available to use in your media blocks. The WordPress media library will allow you to easily find and use these images in your patterns.

Once you are satisfied with your block pattern, you can save it as a draft or submit it to the pattern directory.

Before you can submit your block pattern for the pattern directory, make sure that you have read block pattern directory guidelines.

You can manage all your block patterns by clicking on the My Patterns link. It will show all block patterns you have shared, draft patterns, and patterns you have favorited.

Your patterns

If you only want to create block patterns for your own use, then you can save them as drafts. After that, you can simply copy and paste them from My Patterns page to your WordPress website.

Creating WordPress Block Patterns Manually

You can also create block patterns manually and add them to your WordPress theme or custom snippets plugin.

Simply create a new post or page in WordPress. In the content area, use blocks to create a custom layout or block collection that you want to save as a pattern.

Switch to the code editor

After that, switch to the Code Editor mode and copy all content you see in the code editor.

Copy raw code blocks

Next, open a plain text editor like Notepad and paste that code in there. You’ll need it in the next step.

Now you are ready to register your blocks as a pattern.

To do that, simply copy and paste the following code into your theme’s functions.php file or a site-specific plugin.

 function wpb_my_block_patterns() {     register_block_pattern(         'my-plugin/my-awesome-pattern',         array(             'title'       => __( 'Two column magazine layout', 'my-theme'),             'description' => _x( 'A simple magazine style two-column layout with large image and stylized text', 'my-theme' ),             'categories'  => array( 'columns' ),             'content'     => ' Your block content code goes here'             )     ); } add_action( 'init', 'wpb_my_block_patterns' );  

Now copy and paste the raw blocks data you copied earlier as the value for the content parameter. In other words, you’ll need to replace the text that says ‘Your block content code goes here’ with your block code. Be sure to leave the single quotes surrounding the text in place.

Lastly, don’t forget to change the title and description to your own and save your changes.

You can now visit your website and edit and post or page. You’ll now be able to see your newly registered block pattern in the block inserter.

Add custom block pattern to your post

Remove a Block Pattern in WordPress

You can easily remove or unregister any block pattern in WordPress. Let’s say you want to remove the block pattern you created in the above example.

All you need to do is copy paste the following code to your theme’s functions.php file or a site-specific plugin.

 function wpb_unregister_my_patterns() {   unregister_block_pattern( 'my-plugin/my-awesome-pattern' ); } add_action( 'init', 'wpb_unregister_my_patterns' ); 

In this example, 'my-plugin/my-awesome-pattern' is the name of the pattern we used when registering it.

You can use this code to unregister any block pattern created by your theme or a plugin. All you need to know is the name used to register the pattern.

Remove Core WordPress Patterns

The core WordPress patterns are available to all WordPress users. This means they may be over used and might not even match rest of your WordPress theme.

If you don’t want to use a pattern, then you can simply avoid adding it to your content. However, if you run a multi author WordPress site, then you may want to prevent all users from using these core patterns.

To remove all core WordPress patterns, you need to add the following code to your theme’s functions file or a site-specific plugin.

 remove_theme_support( 'core-block-patterns' ); 

What’s The Difference Between Reusable Blocks and Block Patterns?

Block patterns and reusable blocks both intend to solve a similar problem: provide users with options to easily add commonly used blocks.

However, they are quite different from each other.

For instance, reusable blocks can be edited and saved right inside the post editor, but they are not as flexible as block patterns.

One big difference is that if you make a change to a reusable block, it changes the block on every post or page you’ve used it on.

Reusable block in WordPress

For more details, see our tutorial on how to use reusable blocks in WordPress.

On the other hand, if you insert a pattern and edit it, then those changes only apply to the post or page where you have added that pattern.

Block patterns can also be registered by your WordPress theme or plugins such as block plugins. This allows those developers to offer you a lot more design options to create your post and page layouts.

We hope this guide helped you learn how to use WordPress block patterns on your website. You may also want to see our guide on how to choose the best web design software, or our expert pick of the best email marketing services for small business.

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.

Beginner’s Guide on How to Add a Link in WordPress

Do you want to add a link in WordPress?

There are several ways to add links in WordPress. You can add links in your posts, pages, navigation menu, sidebar widgets, footer area, and more.

In this comprehensive beginner’s guide, we will show you how to add a link in WordPress.

Why Are Links Important?

Links are the bloodstream of the internet. They interconnect websites and web pages to form a World Wide Web of information.

Imagine visiting a web page that has no links for you to click. You would have no option but to click on the back button in your browser.

Hyperlinked text, buttons, and other elements take you from one page to another or from one website to another. Links will tell visitors to your WordPress website where they can find more information on a topic.

When you use links effectively, those visitors will spend more time on your site. They’ll discover more content, purchase more products on your online store, and are more likely to subscribe to your email newsletter.

That being said, let’s take a look at how to easily add links in different areas of your WordPress website. Since this is a detailed tutorial, please use the navigation below to quickly jump to the section you need:

How to Add Links in WordPress Posts and Pages

WordPress makes it easy to add links in your blog posts and pages using the block editor.

Simply edit your post or page, or create a new one.

Next, you need to highlight the text that you want to attach the link to. This selected text is called the anchor text for the link. Now you should click the ‘Link’ button in the toolbar.

Highlight the Text Then Click the Link Button

You’ll see a box where you can enter a URL. A URL is a web address. For instance, WPBeginner’s guide on how to start a WordPress blog has the URL:

 https://www.csemrm.com/start-a-wordpress-blog 

You can simply copy and paste the URL of the post or page you want to link to, like this:

Paste the Link Then Press Enter

You’ll need to click the ‘Submit’ button or press the Enter key to insert the link into your post.

If you’re linking to content on your own site, then it might be quicker to search for the post or page. Type a word or two from your content title, and WordPress will find it:

Searching for a Page to Link to Using the WordPress Block Editor

After you click on the title of the page or post you want, the link will be automatically added.

If you want your link to open in a new tab, then you should click the ‘Open in new tab’ toggle.

Setting Your Link to Open in a New Tab using the WordPress Block Editor

Note: We recommend that you only use this option for links to third-party websites. This way your users don’t leave your website while visiting it.

Adding Links in the Classic WordPress Editor

If you are using the older classic editor instead of the block editor, then the process for adding a link is quite similar.

You’ll need to open the post that you want to edit or create a new one. Next, you should find the text you want to use as the link’s anchor and highlight it. Then, you need to click the ‘Link’ button which should appear on the toolbar.

Creating a Link Using the WordPress Classic Editor

You can then paste the URL you want to link to, or search for the post or page, as with the block editor.

Pasting your URL Directly Onto the Anchor Text

An even quicker way to add a link in both the block editor and classic editor is to simply paste the URL onto the anchor text.

First, copy the URL you want to link to. Then, highlight your chosen anchor text in your post.

Next, you can either right click and select ‘Paste’ or simply press Ctrl+V (Windows) or Command+V (Mac) to paste the URL.

Paste Your Link Directly Into Your Content

WordPress will automatically detect that you’re pasting a URL and will turn the anchor text into a link.

Tip: Take a look at our tips for mastering the WordPress content editor to learn more about using the block editor effectively.

The step above covers how to manually add links to content on your own site. But, manually adding internal links can be time-consuming.

To make internal linking easier to manage, we use the AIOSEO plugin. It is the best WordPress SEO plugin used by over 3 million websites.

They have a Link Assistant feature that will crawl your entire website and automatically find internal linking opportunities.

After installing the plugin, you can go to All in One SEO » Link Assistant in your WordPress dashboard.

This will open up the link assistant dashboard where you can see an overview of the internal and external links on your site.

AIOSEO Link assistant dashboard

On the Links Report tab, you can see suggestions for relevant posts you can link to as well as the anchor text they recommend for best SEO rankings.

You can quickly add these links to your content by clicking the ‘Add Link’ button. There’s no need to open up each post individually.

AIOSEO internal link assistant example

If you have a lot of content on your site, then this internal linking plugin makes it simple to build a contextual relationship between your new and old posts.

How to Add Links in WordPress Widgets

WordPress allows you to add widgets to your site’s non-content areas like the sidebar and footer. Some of these widgets are automated and do not have many options. For example, the Latest Posts widget will automatically show links to your recent posts.

However, if you want to add some custom text with links in your sidebar, then you can use the Paragraph widget.

You’ll need to go to the Appearance » Widgets page and click on the blue ‘+ Block Inserter’ icon in the top left corner. After that, you should drag the Paragraph widget into your sidebar or other widget area.

Adding a Link in a Widget

You can then type in your text and add a link just as you would when adding one to a post or page. Make sure you click the ‘Update’ button to store your new widget settings.

How to Add Links in WordPress Navigation Menus

Do you want to add links to your site’s navigation menu? WordPress comes with a built-in drag and drop menu editor which allows you to create and manage navigation menus on your WordPress site.

Head over to the Appearance » Menus page. If you don’t already have a menu set up, then you can create one by entering a menu name. To learn more, take a look at our beginner’s guide on how to add navigation menus in WordPress.

Adding Internal Links to Navigation Menus

It’s easy to add links to the content on your own website.

Simply select the posts or pages you want to add to your menu on the left hand side, then click the ‘Add to Menu’ button.

Adding an Internal Link to Your Navigation Menu

WordPress will automatically link to your selected posts and pages. You can rearrange the entries using drag and drop.

Adding External Links to Navigation Menus

You can also add custom links, such as a link to another website. For instance, you could add the URL of your Twitter profile to your navigation menu.

Just click the arrow next to the ‘Custom Links’ section on the left. You can then type in the URL and the text you want to use for the link, and then click the ‘Add to Menu’ button.

Adding a Custom Link to Your Navigation Menu

When you’ve finished adding links to the menu, don’t forget to click the ‘Save Menu’ button at the bottom of the screen.

How to Add Title and Nofollow to Links in WordPress

It’s often useful to give your links a title. This is the text that appears when someone runs their mouse cursor over the link, like this:

A Link With a Title

Adding a title often makes it clear where the link leads to. It can be helpful and even reassuring for your readers.

You may also want to add a nofollow tag to external links. This tells search engines not to pass your site’s SEO score to that link because you don’t own or control that website’s content.

However, WordPress does not allow you to add titles or nofollow tags to links with the default editor. Here are two ways that you can add them.

Adding Title and Nofollow Using the AIOSEO Plugin (Easy)

The free All in One SEO (AIOSEO) plugin for WordPress lets you add title, nofollow, sponsored, and UGC attributes to links.

In the block editor, the plugin adds toggle switches for nofollow and other attributes. It also adds a field for a title.

All in One SEO Title and Nofollow in Block Editor

In the classic editor, you can access additional AIOSEO settings by clicking the ‘Link options’ gear icon. This will display an ‘Insert/edit link’ popup where you can enter a title, and click checkboxes for nofollow and other link attributes.

All in One SEO Title and Nofollow in Classic Editor

Adding Title and Nofollow Using HTML Code

If you don’t want to use AIOSEO, then you’ll need to manually add title and nofollow attributes to your links using HTML code.

First, add your link in the usual way, and then change the editor to HTML mode.

If you are using the block editor, then you need to click on the three vertical dots at the end of the toolbar and select ‘Edit as HTML’ to view the block’s HTML code.

Switching to the HTML View of a Block in the WordPress Block Editor

If you are using the classic editor, then you will have to click the ‘Text’ tab to display the whole post as HTML.

Switching to the Text View of a Post in the WordPress Classic Editor

You’ll now see the HTML code for your link. A basic link will look like this:

 <a href="URL">ANCHOR TEXT</a> 

You need to add the title and nofollow attributes so it looks like this:

 <a href="URL" title="TITLE" rel="nofollow">ANCHOR TEXT</a> 

This is how it looks on our demo website (see the screenshot above):

 <p>According to a study conducted by <a href="https://acme.inc/importantstudy" title="ACME Inc Study on Roadrunner and Coyote" rel="nofollow">ACME Inc</a>, roadrunners are 80% smarter than coyotes.</p> 

You can change the title to anything you want. The nofollow attribute should always be rel="nofollow". Don’t forget the double quotation marks around the title and nofollow as your link won’t work correctly without them.

For more information, see our beginner’s guide on how to add nofollow links in WordPress.

Adding Title and Nofollow to WordPress Navigation Menus

The process for making your navigation links nofollow is a bit different.

Underneath the link’s navigation label, you’ll need to enter ‘nofollow’ in the Link Relationship (XFN) field.

Type nofollow in Link Relationship

If you don’t see that field, you’ll need to add it under the Screen Options tab at the top right corner of the page.

Check Link Relationships and Link Target in Screen Options

For complete step-by-step instructions, see our guide on how to add nofollow links to navigation menus in WordPress.

How to Add Links to Buttons in WordPress

Do you want to add a button to your WordPress posts or pages? The easiest way to do this is using WordPress’s built-in Button block.

Once you create a new post or edit an existing one, you should click the (+) icon to create a new block. After that, you should drag the ‘Button’ block onto the post and then type the text for the button.

Add a Link Button in the Block Editor

After that, you can add a link using the ‘Link’ button in the toolbar. This is just the same as when adding any other link using the WordPress block editor.

To learn more ways to buttons to your posts, see our guide on how to add call to action buttons in WordPress.

How to Embed Linked Content in WordPress

You can easily embed certain types of content in WordPress by simply inserting its URL in your post. This is sometimes called creating a ‘content card’ in your post.

Just paste the whole URL into its own paragraph block.

For example, if you paste a Twitter URL, the whole tweet, including images, likes, timestamp, and more will be embedded like this:

Embedding a Tweet by Pasting in the Link

The process is the same for YouTube videos. Simply find the video you want to use on YouTube and copy the URL from the top of your browser window.

Get the URL to Your Chosen YouTube Video

Next, paste the link into your post or page. The video will be embedded automatically.

Embedding a YouTube Video Into Your Post

As well as being great for Twitter posts and YouTube videos, this method also works for many other types of content. You can find out more from WordPress’s support article on ‘Embeds’.

How to Add Affiliate Links in WordPress

Do you want to increase your site’s revenue by using affiliate links? Affiliate marketing provides a steady income to many blogs and websites.

All you need to do is add special referral links to products and services that you recommend. When your visitors purchase these products after clicking your links, you get a commission.

The problem that most beginners face is that each product or website they want to recommend has a different URL. It’s tricky to keep track of these, especially if you’re recommending lots of products.

The best way to add and manage affiliate links is by using an affiliate management plugin. We recommend using either Pretty Links or Thirsty Affiliates.

Both of these plugins work by creating redirect links that send people to your special affiliate link. They look like this:

 www.yoursite.com/refer/partnersitename 

The plugins will add a new option to your WordPress menu where you can add your affiliate links. Here’s how that looks with ThirstyAffiliates. You simply copy and paste your special affiliate link into the ‘Destination URL’ box.

Adding a Link in ThirstyAffiliates

You can set specific options for your link on the right-hand side, such as deciding whether to nofollow it, opening it in a new window or tab, and more.

Setting the Options for Your Affiliate Link with ThirstyAffiliates

Once you’re done, make sure you click the ‘Save Link’ button.

After you’ve set up your affiliate links, you can easily add them to your posts and pages. In a paragraph block, click the down arrow then select the ‘Affiliate Link’ option:

Adding an Affiliate Link to Your Post

Next, type in the start of whatever you named that affiliate link. In our example, that’s “Our Affiliate Partner”.

Finding Your Affiliate Link by Search

You can then click the name and click ‘Apply’ to add the affiliate link to your post.

It’s easy to change an affiliate link, such as when the company you’re linking to moves to a different affiliate program.

You just change the link once in the ThirstyAffiliates or Pretty Links page of your dashboard. The link in your posts will stay the same as before, but will now redirect to the new affiliate link everywhere it’s used.

For more handy affiliate plugins, check out our post on the best affiliate marketing tools and plugins for WordPress.

How to Manually Add a Link in HTML

Occasionally, you might want to add a link to your site using HTML code. This could happen if you need to use a custom HTML block or widget.

You might also need to directly edit a link in a theme file. Just make sure you always use a child theme so you don’t lose your changes when you update the parent theme.

It’s easy to create a link in HTML. To try it, add a custom HTML block to a post or page. You can find this block under ‘Widgets’ or you can search for it using the search bar.

Adding a Custom HTML Block to Your Post or Page

Next, you’ll see a box where you can write HTML. Copy this code into the box:

 <a href="https://www.yourlinkhere.com">Text</a> 

It should look like this:

The HTML Code to Create a Link

You can click the ‘Preview’ tab to see how your code will look in your post or page:

Previewing How the HTML Will Display in the Post or Page

Now click back to the ‘HTML’ tag so you can change the URL to the correct webpage. You can also change the word ‘Text’ to whichever word or words you want to use for your link.

You might like to add a title to the link as we did earlier. You’ll need to include code like this, and you can change ‘This is the title’ to anything you want.

 <a href="https://www.yourlinkhere.com" title="This is the title">Text</a> 

If you want your link to open in a new tab, then simply add target="_blank" to the HTML code, like this:

 <a href="https://www.yourlinkhere.com" target="_blank">Text</a> 

If you want your link to be nofollowed, then add rel="nofollow", like this:

 <a href="https://www.yourlinkhere.com" rel="nofollow">Text</a> 

You can include all of these at once. Here’s an example of a link with a title that opens in a new tab and is nofollowed:

 <a href="https://www.yourlinkhere.com" title="This is the title" target="_blank" rel="nofollow">Text</a> 

That’s how you create a link in HTML, if you ever need to.

An anchor link is a type of link on the page that brings you to a specific place on that same page. It allows users to jump to the section they’re most interested in.

Take a look at the animated screenshot below:

Anchor link preview

These types of links are really helpful when writing longer tutorials or content, so your users can easily jump to the section they’re most interested in.

We have created a detailed guide on how to easily add anchor links in WordPress.

Want to add social share links or buttons on your site?

These links make it easy for your users to share your content on their favorite social networks. Sometimes social share links or buttons are also accompanied by total share count.

Social Share Links

We don’t advise users to add these links manually. Instead, you should always use a social share plugin. We have a step by step guide on how to add social share buttons in WordPress.

We hope this article helped you learn how to add a link in WordPress. You may also want to see our beginner’s guide on how to create a professional business email address, and how to start an email newsletter to grow your audience.

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.