Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How can I temporarily remove content from all pages, but leave up the URL?

I need to turn off all site content, but leave the URL's up so google can still find them.

...at least I think I want to do this. Basically, I am in negotiation with another site about who "owns" the content, but both of us have agreed to remove the content for 10 days during this discussion. However, I was thinking that I'd leave the URL's up so I don't get totally slammed by Google for have the entire site down. Or does it matter if there's no content.

I'd hate to lose my position in Google for being down 10 days. so anyways, is there a way to show a maintenance message for each URL until this is resolved?

share|improve this question
add comment

2 Answers

Depends on what you mean by "content". If you just want to remove the post body then...

function remove_body_wpse_97291($content) {
  return "Content temporarily removed";
}
add_filter('the_content','remove_body_wpse_97291',100);

If you want more aggressive content removal...

function remove_all_content_wpse_97291($content) {
  include('license.txt'); // example loads the WordPress license agreement as raw text; not pretty
  exit;
}
add_filter('template_redirect','remove_all_content_wpse_97291',1);

The URLs stay the same but you replace content.

You could also redirect with (maybe) a 307 Status code, or 302 possibly,...

function redirect_all_content_wpse_97291($content) {
  wp_safe_redirect('license.txt',307);
  exit;
}
add_filter('template_redirect','redirect_all_content_wpse_97291',1);
share|improve this answer
add comment

There is a plugin for that.

Check out Maintenance Mode by Michael Wöhrer. You can configure how long you want the site to be down, use a vanilla or WordPress Login themed page to display your site is in Scheduled Maintenance, you can even create your own template for the page in your theme and use that. It also includes the functionality to send 503 in your headers so that Google knows you are temporarily offline. There is no hit for this.

Even though the plugin hasn't been updated in years, it is a solid well thought out solution.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.