Introducing Search & Replace Everything by WPCode: Bulk Editing in WordPress Made Easy

Category Image 098

Have you ever wanted to make bulk updates to your WordPress site?

Wouldn’t it be nice if you could update hundreds of posts with a single click… without having to update them manually?

If you’re like me and most other smart website owners, then you have at least wished for this solution a couple of times in your WordPress journey.

Today, I am excited to announce the new Search & Replace Everything by WPCode, a free tool to easily perform bulk search and replace operations in WordPress.

Introducing Search & Replace Everything by WPCode

Why Did We Build This Tool?

By default, WordPress does not come with a Find and Replace tool. This makes it hard to do bulk updates on your site.

Especially if you want to quickly update a link on every page, change an image that’s used in multiple areas, or making bulk changes when you’re moving your site.

Website owners either have to update every page manually which is extremely inefficient and time-consuming, or hire a developer to write a SQL query which can be expensive.

And that’s why I decided to create Search & Replace Everything by WPCode.

Search & Replace Everything revolutionizes how you update your content on your site once and for all.

This tool is designed for anyone who manages a WordPress site and wants to save time and avoid errors.

Here are some of the top use cases:

  • Bulk Update Content in WordPress Posts: As the plugin’s name suggests, you can search and replace any content on your website with a single click.
  • Replace an Image Used Across Multiple Locations: Quickly replace outdated images anywhere on your site with the new ones with just a click.
  • Updating URLs After WordPress Migration: When you migrate a WordPress website to a new address, you can replace URLs pointing to the old address. The plugin helps you fix all broken links while also saving you time.

Making Bulk Changes in WordPress Effortlessly

With Search & Replace Everything, our goal is to make it easy to make bulk changes to your website.

Instead of writing complex SQL queries on your own or hiring a developer, you can enter what you want to search for and what you need to replace it with.

Let me show you what makes Search & Replace Everything incredibly powerful yet so simple.

1. Update Everything Quick and Easy

Search & Replace Everything comes with a clean user interface. Just go to the Tools » WP Search & Replace page, enter the content you want to find, and then add the content you want to replace it with.

This simple layout ensures that even non-technical users can perform complex operations without hassle.

Easy to use interface

2. Control Where to Search

Target your changes precisely by selecting specific database tables or searching across all tables for comprehensive updates.

This feature ensures you’re making changes exactly where needed, preventing any unintended modifications.

Select tables

3. Precision Search with Case Sensitivity

By default, the plugin performs case-sensitive searches, ensuring accurate and specific matches.

For example, a search for “WordPress” will not match “wordpress” or “WORDPRESS”.

However, if you need to make your searches case-insensitive, you can easily toggle the option. This allows you to find and replace text regardless of its case.

For instance, enabling case-insensitive search would allow “WordPress,” “wordpress,” and “WORDPRESS” to be treated as the same.

Case Insensitive searches

4. Preview Before Making Changes

Worried about making mistakes? Preview all the changes before you save them. This feature ensures you get everything right the first time.

Preview changes

5. Replace Any Image in Your Media Library

Replacing images used in multiple places? No problem.

Switch to the ‘Replace Image’ tab, find your image, and click ‘Replace’. It’s that simple.

Replace image in media library

6. Track & Undo Changes

You can keep track of Search & Replace activity in the ‘History’ tab. This allows you to quickly review the changes you made and undo them with the click of a button.

Track history and undo changes

Note: This feature is available with the paid plan with an introductory $30 discount.

6. Fast, Even on Large Websites

Performing site-wide search and replace operations consumes server resources, which could slow down or crash a website. Search & Replace Everything is designed to be fast and efficient, even if you have a larger website with tons of data.

With Search and Replace Everything, making bulk changes has never been easier.

What’s Coming Next?

Search & Replace Everything by WPCode provides an incredibly powerful tool for WordPress site owners.

It makes advanced database search and replacement operations quite simple for all users.

Before performing bulk updates, always create a fresh WordPress database backup. I recommend using Duplicator. It’s an easy way to back up your database and restore it with a single click if needed.

We’re truly building something special here. If you have ideas on how we can make the plugin more helpful to you, please send us your suggestions.

As always, thank you for your continued support of WPBeginner. We look forward to serving you for years to come.

Yours Truly,

Syed Balkhi
Founder of WPBeginner

The post Introducing Search & Replace Everything by WPCode: Bulk Editing in WordPress Made Easy first appeared on WPBeginner.

How to Display Any Number of Posts in a WordPress Loop

Category Image 052

Do you want to show multiple blog posts in a WordPress loop?

Using the loop, WordPress processes each of the posts to be displayed on the current page. It formats them according to how they match specified criteria within the loop tags.

In this article, we will show how to display any number of posts in a WordPress loop.

How to display any number of posts in a WordPress loop

What Is the WordPress Loop?

The loop is used by WordPress to display each of your posts. It is PHP code that’s used in a WordPress theme to show a list of posts on a web page. It is an important part of WordPress code and is at the core of most queries.

In a WordPress loop, there are different functions that run to display posts. However, developers can customize how each post is shown in the loop by changing the template tags.

For example, the base tags in a loop will show the title, date, and content of the post in a loop. You can add custom tags and display additional information like the category, excerpt, custom fields, author name, and more.

The WordPress loop also lets you control the number of blog posts that you show on each page. This can be helpful when designing an author’s template, as you can control the number of posts displayed in each loop.

That being said, let’s see how to add any number of posts to a WordPress loop.

Adding Any Number of Posts in a WordPress Loop

Normally, you can set the number of posts to be displayed in the loop from your WordPress admin panel.

Simply head to Settings » Reading from the WordPress dashboard. By default, WordPress will show 10 posts.

Reading settings WordPress

However, you can override that number by using a Super Loop, which will allow you to display any number of posts in that specific WordPress loop.

This will allow you to customize the display settings of your pages, including author profiles, sidebars, and more.

First, you will need to open a template file where you would like to place the posts and then simply add this loop:

<?php
// if everything is in place and ready, let's start the loop
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

	// to display 'n' number of posts, we need to execute the loop 'n' number of times
	// so we define a numerical variable called '$count' and set its value to zero
	// with each iteration of the loop, the value of '$count' will increase by one
	// after the value of '$count' reaches the specified number, the loop will stop
	// *USER: change the 'n' to the number of posts that you would like to display

	<?php static $count = 0;
	if ( $count == "n" ) {
		break;
	} else { ?>

		// for CSS styling and layout purposes, we wrap the post content in a div
		// we then display the entire post content via the 'the_content()' function
		// *USER: change to '<?php the_excerpt(); ?>' to display post excerpts instead

		<div class="post">
			<?php the_title(); ?>
			<?php the_content(); ?>
		</div>

		// here, we continue with the limiting of the number of displayed posts
		// each iteration of the loop increases the value of '$count' by one
		// the final two lines complete the loop and close the if statement

		<?php $count ++;
	} ?>
<?php endwhile; ?>
<?php endif; ?>

Note: You will need to replace the value of ‘n‘ in the if ( $count == "n" ) part of the code and choose any number.

An easy way to add this code to your WordPress website is by using the WPCode plugin. It is the best code snippet plugin for WordPress that helps you manage custom code.

By using WPCode, you don’t have manually edit theme template files and risk breaking something. The plugin will automatically insert the code for you.

First, you need to install and activate the free WPCode plugin. For more details, please see our guide on how to install a WordPress plugin.

Upon activation, you can head to Code Snippets » + Add Snippet from your WordPress dashboard. Next, you need to select the ‘Add Your Custom Code (New Snippet)’ option.

Add new snippet

After that, simply paste the custom code for the WordPress loop that we showed you above into the ‘Code Preview’ area.

You will also need to enter a name for your code and set the ‘Code Type’ to ‘PHP Snippet’.

Add custom loop code to WPCode

Next, you can scroll down to the ‘Insertion’ section and choose where you would like to run the code.

By default, WPCode will run it everywhere on your WordPress website. However, you can change the location to a specific page or use a shortcode to insert the code.

Edit insertion method for code

For this tutorial, we will use the default ‘Auto Insert’ method.

When you are done, don’t forget to click the toggle at the top to make the code ‘Active’ and then click the ‘Save’ button. WPCode will now deploy the code on your WordPress blog and display the specified number of posts in the WordPress loop.

We hope this article helped you learn how to display any number of posts in a WordPress loop. You may also want to see our guide on how to exclude sticky posts from the loop in WordPress and our expert picks for the must-have WordPress plugins for business websites.

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 Display Any Number of Posts in a WordPress Loop first appeared on WPBeginner.

How to Limit Comment Length in WordPress (Easy Tutorial)

Category Image 098

Do you want to limit comment length in WordPress?

WordPress comments encourage discussions around your blog post content. However, you may find that comments that are very brief or overly long are not very helpful.

In this article, we will show you how to easily limit comment length in WordPress.

Limit Comment Length in WordPress

Why Limit Comment Length in WordPress?

An active comment area is a great way to build a community around your WordPress blog. Visitors can give feedback, ask questions, and offer their own points of view on the topic.

However, not all comments are helpful.

We’ve been moderating WordPress comments for well over a decade. In our experience, we’ve found that the most helpful comments are above 60 characters and below 5000 characters in length.

One-word comments are usually not very helpful. In most cases, they are spam comments where the author just wants a backlink from your site.

On the other hand, long comments above 5,000 characters are often rants or complaints. Sometimes, they are not even relevant to the article.

Setting comment length limits in WordPress can improve the overall quality of your comments and discourage spam comments. However, there is no built-in way of doing this in WordPress.

That being said, let’s take a look at how to control comment length in WordPress by setting minimum and maximum limits.

How to Limit Comment Length in WordPress

You can limit comment length in WordPress by adding code to your functions.php file. However, keep in mind that the smallest error while entering the code can break your site and make it inaccessible.

That’s why we recommend always using WPCode to insert code snippets into your WordPress site. It is the best WordPress code snippets plugin on the market that makes it safe and easy to add custom code.

First, you need to install and activate the WPCode plugin. For detailed instructions, see our step-by-step guide on how to install a WordPress plugin.

Note: WPCode also has a free version that you can use for this tutorial. However, upgrading to the paid plan will give you access to more features like a larger code snippets library, conditional logic, and more.

Upon activation, visit the Code Snippets » + Add Snippet page from the WordPress admin sidebar.

Here, click the ‘Use Snippet’ button under the ‘Add Your Custom Code (New Snippet)’ option.

Add new snippet

This will take you to the ‘Create Custom Snippet’ page, where you can start by adding a title for your code snippet. This name won’t be displayed on the website front end and can be anything you like.

Next, choose the ‘PHP Snippet’ option as the Code Type from the dropdown menu in the right corner of the screen.

Choose the PHP Snippet option for comment length limit

Once you have done that, simply copy and paste the following code snippet into the ‘Code Preview’ box:

add_filter( 'preprocess_comment', 'wpb_preprocess_comment' );
 
function wpb_preprocess_comment($comment) {
    if ( strlen( $comment['comment_content'] ) > 5000 ) {
        wp_die('Comment is too long. Please keep your comment under 5000 characters.');
    }
if ( strlen( $comment['comment_content'] ) < 60 ) {
        wp_die('Comment is too short. Please use at least 60 characters.');
    }
    return $comment;
}

This code snippet works by adding a filter hook to preprocess_comment. This filter is run before WordPress saves any comments to the database or performs any pre-processing on submitted comments.

It checks the comment length and displays an error message if it is too short or too long. By default, the comment limit is set to a minimum of 60 characters and a maximum of 5,000 characters in this snippet.

However, to set your own comment limit, just replace the number 5,000 in the code with your maximum limit number.

Similarly, you can replace the number 60 in the code to set a different minimum comment limit on your WordPress website.

You can also change the message that will be displayed on your website when a user exceeds or falls short of the comment limit. Simply type the sentence you want to display after the wp_die lines in the code.

Edit comment limit snippet

After that, scroll down to the ‘Insertion’ section and choose the ‘Auto Insert’ mode.

The custom code will be automatically executed on your website upon activation.

Choose an insertion method

If you only want to limit comment length on specific website pages, then you can also do that.

Simply scroll down to the ‘Conditional Logic’ section and toggle the ‘Enable Logic’ switch.

After that, choose the ‘Show’ option from the ‘Conditions’ dropdown menu and click the ‘+ Add new group’ button.

Enable the Conditional Logic toggle

This will open a new tab where you must select the ‘Page URL’ option from the dropdown menu on the left.

Next, type the URL of the page where you want to limit the comment length in the field on the right.

Now, the code snippet will only be activated on the page with the URL you have just entered.

Type the conditional logic

Scroll back to the top of the page and toggle the ‘Inactive’ switch to ‘Active’.

Finally, click the ‘Save Snippet’ button to store your settings.

Save the comment limit snippet

Now, when a user types a comment that falls short of your minimum comment length, this message will be displayed on their screens.

Users won’t be able to post a comment until it is at least the minimum length you chose.

An Error Message Is Displayed if a Comment is Too Short or Too Long

Similarly, when a user types a comment that exceeds your maximum limit, this message will be show on their screens.

This will help reduce rants and spam comments on your website.

Message preview for a long comment

Bonus: Improve Comment Engagement on Your WordPress Site

Controlling comment length is just one way to increase engagement in your WordPress comments section. This is great for keeping visitors on your site for longer and can even benefit your site’s SEO when users’ comments contain relevant keywords and add context to your content.

You can also easily further improve the comments section on your website using Thrive Comments.

The Thrive Comments WordPress plugin

It is the best WordPress comments plugin that comes with a dedicated moderation board, lets you lazy load comments, allows users to leave comments with their social media profiles, and more.

Plus, the tool enables you to add an upvote/downvote functionality to reduce spam and encourage interesting comments on your website.

Thrive Comments even lets you feature encouraging comments at the top and bury offensive or irrelevant comments at the bottom of the discussion section.

Feature comment from dropdown menu

This allows you to reward users who are adding the most value to the discussion while politely discouraging other users from leaving unhelpful comments.

For detailed instructions, you may want to see our tutorial on how to feature or bury comments in WordPress.

We hope this tutorial helped you learn how to limit comment length in WordPress. You may also want to learn how to increase your blog traffic or check out our list of the best WordPress plugins to grow your site.

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 Limit Comment Length in WordPress (Easy Tutorial) first appeared on WPBeginner.

How to Use Shortcodes in your WordPress Sidebar Widgets

Category Image 052

Do you want to learn how to use shortcodes in your WordPress sidebar widgets?

You can add shortcodes to any page or post using the Shortcode block. However, if you want to use the same code across your entire site then it may be easier to add it to a sidebar widget instead.

In this article, we will show you how to use shortcodes in the WordPress sidebar.

How to use shortcodes in your WordPress sidebar widgets

Why Use Shortcodes in Your WordPress Sidebar Widgets?

Shortcodes allow you to add advanced content and features to your website, including contact forms, tables, random quotes, and much more. WordPress comes with several built-in shortcodes but some plugins also add their own shortcodes.

You can add shortcodes to any page or post using the WordPress editor and built-in Shortcode block. However, if you want to use shortcode across your entire site then it often makes sense to add it to the sidebar.

For example, you can display Instagram photos in the WordPress sidebar using a shortcode provided by Smash Balloon Instagram Feed.

An example of a social media sidebar widget

This content will then appear across your entire WordPress website, so you don’t need to add it each page and post manually. This can save you a ton of time and effort, and helps to keep your site’s design consistent.

With that in mind, let’s look at a few different ways to add and use shortcodes in the WordPress sidebar widgets. Simply use the quick links below to jump straight to the method you want to use.

Method 1: Using the WordPress Shortcode Widget (Easy)

Most free and paid WordPress themes come with widget-ready sidebars. With that in mind, you can often simply add a Shortcode widget to your website’s sidebar.

First, go to Appearance » Widgets in your dashboard. Here, you’ll see all the different areas where you can add widgets in WordPress, including the sidebar.

Adding a shortcode widget to a WordPress sidebar

Simply click on the ‘+’ button and start typing in ‘Shortcode.’

When the right block shows up, drag it onto the WordPress sidebar.

How to add a shortcode to the WordPress sidebar

You can now add your shortcode to the block.

When you’ve finished, don’t forget to click on ‘Update’ to make the changes live.

Publishing a shortcode block in WordPress

You can now visit your WordPress blog or website to see the shortcode in action.

Method 2. Using the Full Site Editor (Works With Block-Enabled WordPress Themes)

If you’re using a block theme then you can add shortcode to the sidebar using the full-site editor. In your WordPress dashboard, go to Themes » Editor.

Opening the WordPress full-site editor (FSE)

This opens the full-site editor, with one of your theme’s templates already selected.

If you want to add shortcode to a different template, then click on the arrow in the toolbar and select ‘Browse all templates.’

Choosing a block-based FSE template

You’ll now see all the different templates that make up your theme.

Simply find the template where you want to add the shortcode, and give it a click.

A block-based WordPress theme

After that, click on the ‘+’ button and start typing in ‘Shortcode.’

When the right widget shows up, simply drag it onto the theme’s sidebar.

Adding a WordPress block to the sidebar

You can now add your shortcode to the widget. When you’re happy with your changes, click on ‘Save’ to make the shortcode live.

Method 3: Using the Custom HTML Widget (More Customizable)

Sometimes you may want to show other content along with the shortcode. For example, RafflePress can add a contest or giveaway to your sidebar using a shortcode. To draw even more attention to the contest, you may want to show a heading above the competition.

An example of a giveaway created using RafflePress

Instead of creating separate Shortcode and Heading blocks, you can simply add the shortcode and text to a Custom HTML block. This helps you arrange the different content in a nice layout. You can also style the block using HTML, so you can control exactly how it looks in the sidebar.

The Custom HTML block doesn’t support shortcodes by default, but you can easily change this by adding custom code to WordPress. After adding this code, you can use shortcodes in any Custom HTML block across your entire WordPress website.

Often, you’ll find guides with instructions to add custom code to your site’s functions.php file. However, this isn’t recommended as any mistakes in the code can cause common WordPress errors, or even break your site completely.

That’s where WPCode comes in.

This free plugin makes it easy to add custom CSS, PHP, HTML, and more to WordPress, without putting your site at risk. Even better, it comes with a library of ready-made snippets including code that allows you to use shortcodes in text widgets.

To start, you’ll need to install and activate WPCode. For more information, you can see our step-by-step guide on how to install a WordPress plugin.

After that, go to Code Snippets » Add Snippet in the WordPress dashboard. You can now start typing in ‘shortcode.’

Adding a code snippet to your WordPress website

When it appears, hover your mouse over the following snippet: ‘Enable Shortcode Execution in Text Widgets.’

You can then go ahead and click on ‘Use snippet.’

Adding shortcode to a custom HTML block using code

This will open the snippet in the WPCode editor. WPCode configures the snippet settings for you, so you can simply click on the ‘Inactive’ switch so that it turns blue.

With that done, click on ‘Update’ to make the snippet live.

Adding shortcode to a sidebar widget using code

Now, you can add a shortcode to any text widget.

Simply go to Appearance » Widgets and type ‘Custom HTML’ into the search bar.

Adding a Custom HTML widget to a WordPress sidebar

When the right block appears, drag it onto your website’s sidebar.

With that done, you can add your HTML and shortcode to the block.

Adding a custom HTML widget to a WordPress website

When you’re happy with how the widget is set up, click on ‘Update.’

Now if you visit your website, you’ll see the shortcode and custom HTML live.

FAQ: Using Shortcodes in WordPress Sidebar Widgets

No matter what theme you’re using, you should be able to add shortcodes to the sidebar using one of the methods above. However, if you need extra help then here are some of the most frequently asked questions about adding shortcodes to the sidebar.

How Do I Change Where the Sidebar Widget Appears?

The sidebar’s location is controlled by your WordPress theme. If you’re not happy with the sidebar’s position then you may be able to change it using the theme settings.

Many of the best WordPress themes let you choose between different layouts. Often, this includes showing the sidebar on different sides of the screen.

To see whether your theme has different sidebar layouts, go to Appearance » Customize in the WordPress dashboard. Here, look for any settings labeled Sidebar or similar.

Changing your theme's sidebar settings

Simply click on this option and look for any settings that allow you to change where the sidebar appears on your site.

For example, the following image shows the sidebar settings in the Astra WordPress Theme.

The Astra sidebar settings

After making your changes, click on the ‘Publish’ button to make the new sidebar layout live.

If you can’t change the sidebar’s location using the built-in settings, then another option is to create a WordPress child theme.

How Do I Add a Sidebar to My WordPress Theme?

If your theme doesn’t have a sidebar then you could create a child theme and then add a sidebar using code.

If you’re not comfortable writing code, then you can also create a custom WordPress theme using a plugin such as SeedProd. You can use this popular page builder plugin to design your own theme and sidebar using a simple drag-and-drop editor.

For step-by-step instructions, please see our guide on how to create a custom WordPress theme without any code.

How Do I Use a Different Shortcode on Each Post or Page?

Sometimes you may want to use different shortcodes on some of your posts and pages.  For example, you might want to show the most popular posts on your archive page and display ads on your homepage.

To learn more, please see our guide on how to display different sidebars for each post and page in WordPress.

We hope this article helped you learn how to easily add shortcodes to your WordPress sidebar widgets. You may also want to see our guide on how to create a landing page with WordPress or our expert pick of the best social media 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.

The post How to Use Shortcodes in your WordPress Sidebar Widgets first appeared on WPBeginner.

How to Easily Disable the Default WordPress Sitemap

Category Image 091

Do you want to disable the default WordPress sitemap on your website?

The default sitemap feature was introduced in WordPress 5.5, and it enables WordPress to publish XML sitemaps for your website automatically. The challenge is that this feature is lacking advanced WordPress SEO features that you need to rank higher.

In this article, we will show you how to easily disable the WordPress sitemap and improve it with a more powerful solution.

How to Easily Disable the Default WordPress Sitemap

Why Should You Disable WordPress Sitemap

An XML sitemap is a file that lists all your website content in an XML format, which makes it easy for search engines to discover and index your content.

Sitemaps are very beneficial for your website as they bring more traffic and improve the SEO rankings of your site.

However, numerous WordPress SEO plugins like All in One SEO, Yoast SEO, and Google XML Sitemaps already implement sitemaps on your website, which results in WordPress pages having two sets of sitemaps.

Duplicate sitemaps for the same WordPress page can confuse search engines and can drop your SEO rankings.

If you’re not using a SEO plugin for your sitemap, then you’re missing out on advanced features. For example, many popular WordPress SEO plugins offer features like Video Sitemap, News Sitemap, RSS Sitemap, etc that you need to outrank your competitors in SEO.

With that being said, let’s see how you can easily disable the default WordPress sitemap.

Method 1. Disable WordPress Sitemap Using WordPress SEO Plugin

If you’re using any of the popular WordPress SEO plugins, then they will automatically disable the default WordPress sitemap feature and replace it with a more powerful solution.

For the sake of this tutorial, we will be demonstrating AIOSEO plugin because that’s the plugin we use on WPBeginner.

All in One SEO is the best WordPress SEO plugin that allows you to easily optimize your WordPress website for search engines and social media platforms. Over 3 million websites use AIOSEO including our own.

By default, All in One SEO will enable their Sitemap feature for you which automatically replaces the basic WordPress sitemaps upon activation.

The first thing you need to do is install and activate the AIOSEO plugin. For more details, please see our guide on how to install a WordPress plugin.

Once activated, you will need to configure the AIOSEO plugin. If you need help, then you can follow our step-by-step guide on how to set up All in One SEO in WordPress correctly.

After that, head over to the All in One SEO » Sitemaps page from the WordPress admin dashboard to review your sitemap settings.

Next, navigate to the ‘General Sitemap’ tab. Here, make sure that the ‘Enable Sitemap’ switch is set to ‘Active’. This will disable the default WordPress sitemap.

AIOSEO sitemap settings

Aside from the General Sitemap, we recommend that you enable the video sitemap, news sitemap, as well as the RSS sitemap on your site to maximize your SEO rankings.

Method 2. Disable WordPress Sitemap Using Code Snippet

You can also easily disable the default WordPress sitemap using code, too. You can add the code snippet in your theme’s functions.php file.

However, the biggest problem in adding code to your functions.php file is that even a tiny mistake can break your website.

That is why we recommend using WPCode to add custom code to WordPress. This free plugin makes it easy to add code snippets in WordPress without having to edit your theme’s functions.php file.

First, you need to install and activate the free WPCode plugin. For further instructions, check out our guide on how to install a WordPress plugin.

Next, go to the new Code Snippets entry in the left-hand menu of your WordPress dashboard. This will bring you to the ‘All Snippets’ page.

Next, just click on the ‘Add New’ button.

Go to Code Snippets and click on Add New

WPCode will then take you to the ‘Add Snippet’ page where you can choose to add your own custom code or search to find an existing snippet from the WPCode library.

As we have to add custom code, simply hover over ‘Add Your Custom Code (New Snippet)’ option and click ‘Use snippet.’

Click on the Use Snippet button

Now you will be directed to the ‘Create Custom Snippet’ page. You can start by typing a name for your code snippet. It can be anything you like.

Then, select a ‘Code Type’ from the dropdown menu to the right. As we will be using a PHP code, simply click on the ‘PHP Snippet’ option.

Type a name for your code snippet and choose PHP as code type

Next, simply copy and paste the following PHP code snippet in the ‘Code Preview’.

add_filter( 'wp_sitemaps_enabled', '__return_false' );

It will look like this when you’ve done so.

Paste your disable sitemap snippet

After pasting the code, scroll down to the ‘Insertion’ section where you will find two insert methods.

Simply choose the ‘Auto Insert’ option since you want it to run sitewide.

Choose an Insertion mode

Now, go to the top of the page, toggle the switch from ‘Inactive’ to ‘Active’ at the top right corner, and then click the ‘Save Snippet’ button.

Once, you have saved and activated the code snippet, it will be active and the default WordPress sitemap disabled.

Save your snippet

We hope this article helped you learn how to disable the default WordPress sitemap. You may also want to check out our ultimate WordPress SEO guide to improve your rankings, and see our comparison of the best managed WordPress hosting.

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 Easily Disable the Default WordPress Sitemap first appeared on WPBeginner.