How To Display A “Page Removed” Notice In Place Of The Page Itself( 'Takes about 18 minutes to read. )

* ~ Welcome to the website where it's all good. ~ *

This Is Another Original Unique WordPress Page Theme-Hack Developed by Sharron-Idol – back in 2009, before her music & entertainments career in earnest started.

Sharron-Idol advises you to back up your WordPress files and folders before you embark on this; then if you do make a cock-up and end up wrecking a file for some unexplained reason; you can simply replace it from backup.

I’ve recently published a post about my development of a non-plugin HTML sitemap. – That brought to mind this development which I posted about on my old site, but which isn’t mentioned here on this better site yet. I’m just about to change that: I’m re-writing the original post, so bear with…

There may be an instance with your (self-hosted) WordPress blog, where you’d like to temporarily withdraw a page from viewing. Maybe you’d like to do so permanently even.

Of course; when you delete the page you’ll have to let the search-engines know, and you’ll have to go into your database and remove its entry. All the search-engines are still displaying the URL of the page, and going through the routine of informing them all that the page has been removed and waiting for them to remove its listing is a load of hassle and wastes time that could otherwise be used more productively.

Even if all the search-engines remove the URL; there’s still a good chance that people have it bookmarked in their browser:

When they go to refer to it later they get either your 404 page or a server error maybe. – That doesn’t look all that professional; I think you’d agree.

What’s needed is a  notification that the page has been (temporarily or permanently) removed when the visitor visits it. The search-engines still point to it, and they’ll eventually get the idea that there’s nothing to see there; but the visitors don’t get a 404, there’s no hole in your database, and Google isn’t nagging you that it’s looking for a page on your site that doesn’t exist. You could alternatively delete the posts totally and design in such a notification. – Some text saying “This page is (temporarily) unavailable”, perhaps, on a page-by-page basis, assuming that you wanted to remove more than 1. – Once again however, it’s all hassle which uses up your time in which you could be doing something much more productive.

– Wouldn’t it be great if there were a button somewhere within the WordPress GUI that you could just click and the page in question instantly shows as unavailable, or displays a pre-assigned message on it rather than the original page’s content? That would save a heck of a lot of time and hassle, yeah? – all with a single click



Well the good news is that something very similar to the above can be accomplished with relative ease, and there’s no need to make any changes to the WordPress core: This hack is all done in your current theme’s folder, and there is very little chance of anything going tits-up, even if you do make a total pig’s ear of it.

Good ol’ genius Sharron-Idol to the rescue then. Smile  – Let’s talk about how we’re going to accomplish this fete: –

This post was originally written for creating the template in the Twenty Ten Theme by the WordPress team. When I started this website and all but abandoned my old site, I went from Twenty Ten theme to Twenty Fifteen theme (At least – my own hack of the original themes.). this was quite an anti-climax as, although both themes were in some ways quite similar in design, the Twenty Fifteen theme uses a number of extra files to accomplish same as the Twenty Ten theme. I found it strange that the first part of the header file generates the top-half of the sidebar in Twenty Fifteen; but stranger still the page.php page-template appeared rather empty, until a further investigation of the PHP code gave light to the fact that the PHP was calling a subsidiary file, content-page.php to run the loop in and actually generate the page & its content.

Let’s look at the basic structure of a page before we do anything else, ignoring the fact that Twenty Fifteen uses an extra content file: Usually there are three, maybe four, main sections involved.

How the existing template structure works

The basic sections of the theme which create the page are the header, the page template itself, the sidebar (if you’re using one.) and the footer. – Let’s start with the header: –

The header is always called first by the page templates PHP. Following the header, the page template itself then executes its loop; generating the page and its contents. The page templates PHP then calls, first the sidebar – if there is a sidebar used with that particular template – and then after the sidebar’s appeared – if there is a sidebar called – it then calls the footer… And the footers PHP executes and finishes off by creating the bottom of the page, as well as providing hooks for a multitude of plugins to run.

There’s More…

So, if we were to remove the page template altogether, then no part of the page in question would appear. There would be nothing to call the header, footer, etc. – Nothing at all would display.

From a slightly different angle: The page template – as an actual object – itself doesn’t call the (sidebar and) footer: The  php code on the page template is what calls the (sidebar and) footer. Likewise, the php content of the page template is what causes the pages’ content to be displayed. – Ordinarily that’s a good thing, but in this case we don’t want the page’s content to be displayed. – So, in order to accomplish our goal, we need to remove the php that displays the page’s’ content from the page template, but not the php that calls the (sidebar and) footer. – Nor the PHP that calls the header.– If we could do that then only the header and (sidebar and) footer would appear: The page’s content wouldn’t. = Target neutralised because the page that we didn’t want to display any longer no longer displays.


“- Just one goddam cotton-pickin’ minute there…”

You’ve seen the flaw in that planning already haven’t you? – Doing that to the one and only page template will mean that no pages are displayed. – None of them.

Sad smile

– What we could do with is another page template; a second page template in other words. Allow me to explain why: –

‘See if we could, under normal circumstances – e.g. for all pages that we want displayed normally – , use the standard page template, but have a second page template as described above that we could call in the case where we didn’t want the pages’ content displayed, then we’d be in clover, problem solved!

Now here I’m thinking that the editor in the WordPress UI does actually give us a choice of templates from within the theme files to use for an individual page; so that’ is as good a way as any of selecting an alternative template.

Let’s make an alternative page template: –

OK; so we first of all want a second page template. – Where is the best place to find a second page template?

Answer = The original page template.

“But there’s only one of those.”  you interject.

Not if we copy it: Then there are two. Two identical page templates, but nevertheless two of them. We can change the “identical” thing forthwith: Let’s just get the second one created before we go any further.

(Maybe there is more than one available page template in your theme; but I’m assuming there’s only one. If there are more than one it makes no difference; we still need to create one more. – Read on… )

OK to copy a page template: We can’t really do it while in WordPress can we? – So first things first: We need an experimental area on our local machine’s hard-drive to work in: –


On the Desktop create a folder called “php lab”. I had one on mine at time of writing – and it was already in use for a number of projects. – You need one too. – So do that. Now we need to retrieve a copy of your blog’s current theme: Open up your ftp client, (I use FileZilla 64-bit. (Because I have a 64-bit Windows 10 operating system. – But it doesn’t matter whether you have a 64-bit or a 32-bit operating system. (If you want to use FileZilla then there is both a 32-bit and a 64-bit version available which works with Linux and with Windows. I’m not sure if there is one that works with Mac though: I don’t think there is at time of writing.)) Copy the theme folders and files of the theme you’re currently using to a folder in the “php lab” folder on your desktop.

(To get to your blogs’ available themes files you’ll need to go to the root folder of your web-space, in which you should see the WordPress core folders. (WP-admin, WP-includes, WP-content, etc.) You want to open the folder WP-content, or the equivalent thereof if you’re security-conscious and have changed the prefix, in which you will see a folder titled “themes”: Open that, find the folder with the name of your current theme and download it to the folder “php lab” on your desktop.)


Next: There should be a file in the copy of your current theme’s folder called “page.php”. Copy it; so that you have a file called “Copy of page.php” We need to open it. To do this we either need the default Notepad program that ships with Windows, (Or the Linux or Mac equivalent if you’re using Linux or a Mac.) – Or better still, a nice program called Notepad++. (I think it’s available for Linux and Mac in addition to Windows.) Google it and install it if you don’t have it installed and you want to do more coding of any kind: It’ll be most useful to you in the future.

When you click on the file “copy of page.php”, you may find, if you’ve never opened a php file before, that your computer doesn’t have a clue what to open it with and asks you to tell it what to open it with. Associate php files with either Notepad++, if you have it installed, or Notepad if you don’t and don’t want to install Notepad ++ for whatever reason.

Begin the Operation

OK. – Open the file page.php. Inside it, as its’ suffix suggests, you’ll see a load of PHP. This is a copy-file though, and this file is going to end up as our second page template. – Bear with me here – Most of the PHP in the original file is surplus to requirements – particularly the loop – because we don’t want the new page template to display the contents of the page. – Displaying the contents of the page is what a lot of all that PHP is for. – Therefore we can remove most of that PHP… Later : –

Before We Do That…

At the very top of the file you’ll see some PHP that looks similar to this. (This is from the Twenty ten theme.) : –

< ?php


* The template for displaying all pages.


* This is the template that displays all pages by default.

* Please note that this is the WordPress construct of pages

* and that other ‘pages’ on your WordPress site will use a

* different template.


* @package WordPress

* @subpackage Twenty_Ten

* @since Twenty Ten 1.0


The text-part of this may be totally different in the theme that you are using; but whatever the case, focus on the top line that starts with < ?php right down to */  . That piece of php is identifying the file to WordPress as page.php. We already have page.php existing in the real in-use directory back on the web-space; so if we’re going to copy this file back to the same folder as a new template when we’ve hacked it up, the last thing we want is for WordPress to recognise this folder as another page.php – because WordPress may be good, but it isn’t clever enough to understand the notion of two files with the same name functioning differently. – Comprenez-vous? – So we are going to have to change that piece of PHP to identify the file to WordPress as a different template file.

Hack it

Let’s change things a bit, to make WordPress think that the file is called “deleted_template.php”: Delete the previous php shown above and add the following in its place.

*DO NOT remove the line “get_header(); ?>” : –

< ?php


Template Name: deleted


Now WordPress will see that file as another template; a template named “deleted”.

In fact – let’s change the name of the file properly; since WordPress is gonna call it by another name we’ll do the same: Rename the file name from page.php to deleted.php .

– There we go: WordPress will now see that file as deleted.php and so will we: Because the file is now called deleted.php, and even the computer/WordPress agrees. – ‘Cool as a cucumber. Smile

*Feel free to take a break at any time if you think this is going on a bit long. Go have a cuppa, and a ciggy if you smoke, and then come on back to this and we’ll press on – like a towel.

Next; Hack it Some More

OK. – So far so good: We’ve got two different page templates which both we and WordPress will recognise as such. Now we want to make the template that we created; namely deleted.php, do what we want it to do.

As I said earlier on; most of the php in the page template is displaying the page… and the comment-area, blah blah. – So if we remove the php that is causing the page to display we’ll have only the header + the (sidebar and) footer displayed when any page, no matter what its content, uses that template. – Therefore; open up deleted.php if you’re working in Twenty Ten, and remove everything but the piece of PHP that we’ve just added that identifies the template to WordPress, leaving only that, AND the opening get_header(); ?> immediately following it that closes the php statement; and also the final ( < ?php get_sidebar(); ?> and ) < ?php get_footer(); ?> lines.

The file should now be rather empty of php content and should read like this: –

< ?php


Template Name: deleted_template


get_header(); ?>

< ?php get_footer(); ?>

( You might also have a line that reads like this: < ?php get_sidebar(); ?> In my honest opinion you may as well remove that too; as a sidebar will look odd with no page content. – It’s up to you.)

If we were to use this code in the new template inside WordPress as it is, in conjunction with a page, then it would not display the page content; but rather would display only the header and the footer, and that’s exactly what we want. – Also – We need a bit of text between the header and the footer to make it look as if there used to be something there; I.O.W tell the readers that the page has been removed: –


Add something like the HTML line that I’ve added in the following example. – Put whatever content you prefer in it; I’ve just added what I want to use in the example. I’ve colour-coded it with an explanation of what does what for those of us who are not familiar with HTML coding: –

< ?php


Template Name: deleted_template


get_header(); ?>

< h2 align=”center”>This page has been deleted by the site’s administrator for some reason. close angled bracket, slash, h2>

< ?php get_footer(); ?>


Key: –

The HTML in purple is the opening and closing paragraph-tags. You’ll notice that the opening tag aligns the text to the centre of screen. –

(There is no need to close the alignment as the closing

tag does this also.)

The HTML in red is the header2 opening and closing tags. Again the alignment is to the centre of screen. –

(There is no need to close the alignment as the closing tag does this also.)

The HTML in blue is the opening and closing tag to produce bold type. –

The text in brown is just that: Text. Because it is not between angled brackets thus <>, the computer reading it doesn’t treat it as HTML but rather as text to be printed on the screen.

I hope my explanation of this HTML was clear enough to anyone not in the know.

We’ve almost finished; so save your work and close the file deleted.php . Use your FTP client to upload it to the same location on your server in the current themes’ folder; that is yourdomain/wp-content/themes/yourcurrenttheme/deleted.php. That’s got that bit done: Now we can close the FTP client because we won’t be needing it any more for this operation. I suggest that you keep the folder “php lab” on your local machine. It may well come in handy at a later date; and it’s only taking up a few kilobytes.

The good news is that we’ve nearly finished. – ‘Only a few more things to do now: –

…And Finally: –

Go into your WordPress Admin page and click on the pages tab in the sidebar on the left. Open an existing page for editing; any page, but preferably a page that you’re not too fussed about. In the section “Page Attributes” in the sidebar on the right, click the arrow to release the drop-down list of templates. You’ll see deleted_template in the list. Select it as the template associated with that particular page and that particular page will no longer show. Anyone browsing to that page will see only the header and the (sidebar and the) footer. They will also see the text part of the HTML you added between the header and the footer. In the case of my own file’s displayed HTML it says: –

This page has been deleted by the site’s administrator for some reason.


The page itself hasn’t been altered in any way; it’s just not showing, and the message that you added to the template that you just created is showing. Any time that you want the page to display again as normal, simply associate the other – or any of the other; if you’ve created more or there were more than one to begin with, templates with it. (I’ve just been through how to create new page templates, so now you can create as many as you like.) You can now cause any of the existing pages to vanish and show a notice that they’ve been suspended from view; just by selecting the deleted_template template from the “Page Attributes” section of the page’s individual edit-panel in the WordPress UI.

More Blah…

Added January 2018:
As I mentioned up above; I used this template-replacement technique on this particular website that you’re on now. – It’s only officially 2 years old, but some pages are already dated, no longer relevant, or just badly-written crap that I don’t want to display any more.

Also as mentioned above; this theme – which used to be the TwentyFifteen theme by the WordPress Team before I hacked it up – uses a somewhat different and more complex structure for its template-hierarchy than most other themes I’ve come across to date. – But I conquered it intellectually and adapted the process accordingly.
– Yes it was a pain-in-the-arse; but needs must. 0_0

Here’s an example of one such page; now disused because the offer on it is out-of-date – so therefore it’s cloaked with the deleted-page template mentioned in this article.
– You don’t have to do it in the same style of course but you might like to add a few of your own little quirks to it to make it more uniquely ‘yours’.

I added a “site doctor” animated character to the template; just to spice it up a bit. I also added a PHP-routine advertising the latest 5 posts, so that disappointed visitors can at least be urged to read something if they so choose. – Most of the posts will urge them towards or into a sales-funnel of some description; that or just ask them to join my emailing list if nothing else.
I like wanted to add something beneficial to this article; which was originally written in 2009 on my old website, with a first re-write in 2010, and subsequent additions + transposing to this site, to date. – But to be truthful there is very little left to add, and further additions and updates appear futile.
– Therefore: End of addition.

– It’s easy when you know how, eh?
Smile S to the H to the A to the Zee,
to the Zee to the A. – L.I.V.E.
– Shazzalive is alive!

Thumbs up


WordPress is just so incredibly versatile. There is no end to the number of ideas and hacks that one can create with it!

“Kind’a” Copyright ( – ?) – But Not.

I think this is my original idea: I’ve certainly never seen it online before; and as far as I’m aware, nobody else has come up with it yet. I’m claiming it as my own anyway. If anybody wants to dispute that then please contact me using the “Contact Sharron-Idol” form.

I’m not saying that you can’t use this idea on your own site, of course you can if you wish. – Heck I’m showing you how you can do it yourself; and to try to stop you from doing so would be going against the spirit of the freedom of WordPress and Open Source software. – So please don’t think that I’m stopping you from doing likewise to me, or telling your friends how to do it, or whatever. All I’m saying is that I want to be known as the person from whom the idea originated. 🙂


*This hack only works with PAGES: I have yet to devise a method for doing this with regard to posts.*

– Now I know that you might prefer to have a different message displayed than This page has been deleted by the site’s administrator for some reason; but I’ve already showed you in great detail how everything works… And therefore if you want to edit the displayed message it’ll be child’s play for you to do it in the example that I’ve showed you.

In fact I personally have created a PHP loop which advertises the last few posts underneath the notice that the page has been suspended. – That subject is beyond the remit and scope of this article however – so I won’t be dealing with that right now.

If you’re a php-geek then please feel free to make further improvements to my code: As I said there’s no copyright; all I’m asking is that I get credit for the initial idea: If you can turn it into a plugin and/or make a million from re-coding it then good on you. – Do it. (A 1% donation would be nice if you made that much – but do it all the same. 🙂 )

You know by now that you’re aching to join my mailing-list of course. You can do so by either looking around for one of the many means of doing so on this site, or by clicking this link. – Have a great day.



If you like my spiel, or my music, or both - even my geekiness; then I'd like you to come back some time. - In fact I'd like to stay in touch with you, and have you come back here to this site sometime.

The only way I can think of to achieve this is to ask you to leave me an email address on which I can contact you... So I'll tell you what I'll do: I'll give you almost 30 minutes of my self-composed mix in exchange for your email address. - 'Good deal yeah? - 'Great, we're singing from the same lyric-sheet here, as it were.

When you enter your email address below and click "Get It Now", you'll be taken to my "Thank You" page, where you can download your music, and click on links to more of my stuff if you're interested too.

Since I will then have your email address I'll send you email from time to time; like when I have something interesting to say, or when I release something, or even when I think there's something I've found that you'd be interested in.

You can unsubscribe from these emails at any time if you get fed up with getting them, and I won't complain about it. - And you won't hear from me again; unless you re-subscribe.

'Sound good to you? OK let's do this: 'See the inset below? Follow the instructions - it's really easy - and we're away.
'See you there.

*Opt-in for Sharron-Idol's emailing list - stay connected with this great new site...

avatar standing next to 'join emailing list' sign

There's an instrumental mix waiting for your ears.

Go on - hit the button: - You know you want to hear the free mix. :)

SPAM is EVIL - I am an angelic artist and I will NEVER spam you. 'Promise.


Turn up the sound of Sharron-Idol!



body-footer & footer-underline separator used with pages on