How do I customize the error page of a subweb?

If you use a WordPress Multisite network, it is likely that you had to archive, suspend or delete one or two websites.

If the network is for your own use, you may have created a website and then realized you don't need it anymore. You may have moved it to a standalone WordPress installation or you may have accidentally created a duplicate.

If the network is open for users to create their own websites, you will need to delete some spammy blogs over time, or perhaps delete a website that someone created as part of a free trial but that doesn't. did not continue.

And if you use your network to host clients' websites, you may have had a website migrated to its own WordPress installation or deleted when the client ceased operations or was transferred to another developer or web host.

By default, if someone visits a website that you have disabled, they will see a rather dark default screen saying that the website has been suspended.

But what if you want to personalize this screen or add some personalized content such as a link encouraging visitors to visit your main website or start their own blog?

In this tutorial, I will show you exactly how to do this. I will show you how to create a file in your directory wp-content which replaces the default file for this screen, and how to customize it.

But before we do that, let's take a look at the different options you have for suspending a website, and what users will see when you do that.

Suspend websites in your network: the options

I have to admit that I find the terminology surrounding the removal and suspension of websites in a network very confusing. It's not entirely clear what each post means and sometimes when you make one the system will tell you that you made another.

So let's have a recap on the options for removing websites from your network.

Here is the details screen of the Multi-site sites management window which you access by going to My sites> Network administrator> Sites :

configure a network mutlisite.png

There are four options to delete the site:

  • deactivate cancels the activation step performed by users when they subscribe to a website. It does not permanently delete the website which can be reactivated at any time. But the website administration screens are no longer accessible.
  • Archives report that a website is archived so that it cannot be accessed by users. Admin screens can be viewed but not the front-end. Again, you can easily archive a website at any time and it won't be deleted.
  • Spam does not delete the website, but marks it as spam. It will be unavailable (front-end and admin) until you decide otherwise.
  • Remove delete the website. Use this option with extreme caution!

The default screen for suspended websites

WordPress has a default screen that it displays when a website is deleted.

Here's what you see in each scenario.

Disabled websites

If a website is disabled and someone other than the network administrator (logged in) is viewing it, a default screen will appear:

this site is no longer available.png

Archived websites and websites marked as spam

If you mark a website as spam or archive it, you will get a different screen:

How to customize the error page of a subwebs

These screens are very basic. They don't give a lot of information to the visitor or explain what is meant by "no longer available" or "archived or suspended".

So let's create ours.

Note that if the website has been deleted, you will not see any of these screens - instead you will be taken to a 404 page on the main website.

Creating a page for disabled websites

Creating a new page to display when someone visits a disabled website is pretty straightforward. You just create a new file called Blog-deleted.php and put it in the folder wp-content de your network. This file will then be used to display a custom page instead of the default page.

Note that this is in the folder wp-content network and that the same file will be used for all websites on your network that are disabled. This means that you need to create something generic, rather than something specific to a website on your network.

Note: the title of this file is very confusing. It does not apply to deleted websites, just disabled ones!

The page you create must be independent: it will not use the website theme or call for plugins or additional files. You must therefore include any style in this file or call an external style sheet, which you will put in a styles folder in your folder. wp-content .

You will also need to include the section <head>and tags <body>opening and closing as these will not fit into your theme's header or footer files.

For the sake of simplicity, I will create a very simple file with all the style that is included.

You can start with a completely empty file if you want or you can copy some of the content from your theme files. On the one hand, I copied the contents of the file header.php of my theme and I ai changed significantly, then manually added the rest of the tags.

Here is the content of my section<head>:

" /> <? php / * * Print the <title> tag based on what is being viewed. * / global $ page, $ paged; wp_title ('|', true, 'right'); // Add the blog name. bloginfo ('name'); ?>
 .content {
 width:500px;
 height:500px;
 margin:0 auto;
 background:#999;
 position:absolute;
 left:50%;
 top:50%;
 margin-left:-250px;
 margin-top:-250px;
 padding: 10px;
 }
 .content p {
 position: relative;
 top: 50%;
 transform: translateY(-50%);
 text-align: center;
 font-size: 18px;
 font-family: 'Helvetica Neue', Verdana, sans-serif;
 }
 a:link,
 a:visited {
 color: #fff;
 text-decoration: underline;
 }
 a:hover,
 a:active {
 color: #fff;
 text-decoration: none;
 }

This gives me the required content as well as some metadata and style.

Now for the <body>:

>  This blog has been deleted, sorry! To create your own site, please visit The Main Network Site . ',' Compass'); ?>

There's not much in the body - just an element for the content, with a paragraph inside and some text, which is translatable. This includes a link to the main website, which you might want to include if your network allows user registration.

You can also link to a different website on your network if that website has been replaced or on a page on your main website explaining your website removal strategy where you want it.

Let's take a look at the screen we get now if a website is disabled:

It's not very pretty right now - you might want to add a different style, colors, and maybe a title. But it shows you that it is possible to override the default page for deleted websites and add whatever you want.

Creating a page for archived websites

If you also want to create a custom page for websites archived or marked as spam (and why not you?), You will have to create another file, also in your folder. wp-content . That's what we call Blog-suspended.php .

I created another file which is identical to my file Blog-deleted.php but with slightly different text. Here is the code:

" /> <? php / * * Print the <title> tag based on what is being viewed. * / global $ page, $ paged; wp_title ('|', true, 'right'); // Add the blog name. bloginfo ('name'); ?>
 .content {
 width:500px;
 height:500px;
 margin:0 auto;
 background:#999;
 position:absolute;
 left:50%;
 top:50%;
 margin-left:-250px;
 margin-top:-250px;
 padding: 10px;
 }
 .content p {
 position: relative;
 top: 50%;
 transform: translateY(-50%);
 text-align: center;
 font-size: 18px;
 font-family: 'Helvetica Neue', Verdana, sans-serif;
 }
 a:link,
 a:visited {
 color: #fff;
 text-decoration: underline;
 }
 a:hover,
 a:active {
 color: #fff;
 text-decoration: none;
 }
>  This blog has been suspended, sorry! To create your own site, please visit The Main Network Site . ',' Compass'); ?>

Here is the page you get when you visit an archived website:

Again, our visitor has more information and a link to the main website. You can replace this with whatever you want.

More advanced options

You can bring this technique further.

The first thing you can do to improve your code is to separate styles and add them to a stylesheet in your folder. wp-content. You would then call this stylesheet on both files for suspended and deactivated websites, which means you only need to code the style once.

If you want a different style for each of the two pages, you can add an additional class to the tag body for each file and target it.

To call your new style sheet, add this line of code to the section <head> your file:

You can also import the stylesheet from the theme that has been activated for the suspended site. Beware of doing this - if the website is spammy, there may be a problem with the code, or you deleted the theme after disabling the website.

But if you want to do that, you can include the theme style sheet with this line in the <head>:

" />

You can take this a step further by using the function to call specific theme files such as the header or footer. But again, be careful as the theme may get deleted or corrupted. If you do, it gives you the option of giving each blog a hanging page that looks unique.

Another option is to use your main site's stylesheet, which means you can create all of your hanging / deactivated screens with your own branding. To call the stylesheet from the main theme, you need to add this code in the tag <head>:


" />

You will then use the appropriate elements for your page markup so that it works with your main blog theme - or you can invoke files from that theme using the tag include.

Finally, you can use conditional tags to check blog ID, blog status, or whatever else you want to check and then distribute the content accordingly.

But if you don't want to go that far, a simple page like the one we've created above will provide visitors with more information than the default, and allow you to direct people elsewhere in your network.

It's easy to override default pages for disabled websites

If you follow the steps above, you can quickly and easily replace the default pages of archived, suspended, or deleted websites from your network.

This way, you will be able to give visitors more information than what the default screens provide, and provide a link to your main website so they don't just leave your network.

Discover also some premium WordPress plugins  

You can use other WordPress plugins to give a modern appearance and to optimize the handling of your blog or website.

We offer you here some premium WordPress plugins that will help you do that.

1. Social Share and Locker Pro

Another big contender in our lock plugin list is Social Share and Locker Pro. This WordPress Plugin premium offers tons of features almost the same as the Bloom plugin seen above.

social share locker pro wordpress plugin

You will find as main features: a cshareholder and Likes, the dunlocking the content after sharing, the partage of several types of content, Visual Composer integration, a ffet at the mouse overflight, a mise page 100% responsive, a genabler of shortcodes, et more.

See also 9 WordPress plugins to activate the connection via social networks.

Download | Demo | Web hosting

2. Youtubomatic 

Youtubomatic is a new WordPress Plugin premium which will be especially useful if you are a blogger video. When this WordPress Plugin is active on your website, it can automatically import videos from YouTube and publish them to WordPress using the native YouTube API. 

Youtubomatic wordpress plugin create automatic blog

Once this feature is enabled, you can download a video to your channel from YouTube simply by accessing it through a link.

You'll be able to import both posts and comments to YouTube to provide engaging content on your blog. The plugin reduces the duplicate content with some advanced features, like a random phrase generator and a synonym generator that will make your publication different from the source. Its support for text rotation enhances the value of SEO.

See also How to upload your bulk media on WordPress

Google robots are likely to treat the content generated by this plugin as unique. You will be able to define the rules based on which the posts will be generated and search the content using filters and options. 

Personalized shortcodes are available for inserting videos into a post to display a list of videos suggested by a keyword search or to display videos from a playlist.

Download | Demo | Web hosting

3. Ajax Search Pro for WordPress

Ajax Search Pro is one of the best WordPress plugins premium real-time search bar on WordPress. It is highly customizable, with many features and options, and delivers the best possible results.Ajax search pro live wordpress search filter wordpress plugin
You can replace the WordPress search bar with a more efficient and dynamic search engine. In addition, this WordPress plugin has more than 60 colorful, and fully customizable themes that will save you time.

See our article on 10 WordPress plugins to improve the visual of your website

So you can focus more on the visual presentation of your search form.

Download | Demo | Web hosting

Recommended Resources

Find out about other recommended resources to help you build and manage your website.

Conclusion

Here! That's it for this tutorial on how to customize the error page for WordPress sub-websites. Feel free to share this article with your friends on your favorite social networks

However, you will also be able to consult our resources, if you need more elements to carry out your projects of creation of Internet sites, by consulting our guide on the WordPress blog creation.

If you have suggestions or remarks, leave them in our section Comments.

...