0

I was developing a new WordPress website so i added this function at the end of the "functions.php" file to redirect all users to a /maintenance-mode page in my website except me(My IP-Address):

function wp_maintenance_mode() {
    if ( !is_page( 2075 ) && $_SERVER['REMOTE_ADDR'] != "111.222.33.44" ) {
        wp_redirect( home_url( 'maintenance-mode' ) );
        exit;
    }
}
add_action( 'template_redirect', 'wp_maintenance_mode' );

After finishing the website development and i wanted to put it alive i have commented this function by putting it inside comments /* */ .. When i now access the website strangely the maintenance-mode still appears when i access any page. I tried to remove the comments but it still goes to the maintenance-mode page!

It is getting me crazy and i can't find why this happens. I searched everywhere, in the database, in my files for an access to the maintenance-mode page but i can't see any.

Do you have any idea what may be causing this?

4
  • Do you use any cache plugins like W3 total Cache?
    – Ranuka
    Nov 9, 2016 at 3:41
  • No, i don't use any Caching plugins!
    – Brad
    Nov 9, 2016 at 4:29
  • Can you go to dashboard -> Settings->Permalink and click the save button again? I don't think this will works. But just do it and let me know.
    – Ranuka
    Nov 9, 2016 at 4:34
  • 1
    @Ranuka .. Thanks a lot for the suggestions :) .. I have posted what fixed it in a new answer. Hope someone will not face the same stupid issue.
    – Brad
    Nov 9, 2016 at 4:42

2 Answers 2

1

I was able to fix it finally! .. All i did is deactivating all WordPress plugins then reactivating them again, and all worked fine .. Just that!!!

0

Have you tried to take the function out of functions.php file altogether? I had a similar issue, not with a maintenance function but a function I had in my code that wouldn't go away, I tried to comment it out as well.

I had to remove the function from the file, clear my cache, and upload the fresh file.

Once that was done - I added the function back into the file, commented it out and all is well!

1
  • I have renamed the whole file "functions.php" to "functions1.php" and still the same thing happens!!! ... By the way the homepage loads fine, but any other page redirects to the maintenance page. I don't know why too!
    – Brad
    Nov 8, 2016 at 19:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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