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.

I'm using SMOF for my Theme Options. I added a switch option in case of the administrator wants to change the homepage (whatever it is) to other page (in this case, a "coming soon" page). If don't, redirect to the site's default page. By now I have this code:

<?php 
global $data;

if ($data['general_soon_maintance'] == 1 ) {

    wp_redirect( 'coming-soon-page' );
    exit;   

} else {
    // if OFF
    wp_redirect( home_url() );
    exit;   
}

?> 

Using the code below, the browser returns a redirect loop.

If I write another page on the else statement (instead of the function home_url()) it redirects to the page normally. The if statement works well too. I think the main problem is with the home_url(). Any sugestions?

share|improve this question
    
There is nothing wrong with home_url(), there can be reason it needs a trailing slash, so use this instead and see if it works wp_redirect( home_url('/') ); exit; –  Maruti Mohanty Dec 17 '13 at 7:58
    
You may also check this from WPSE to confirm whether you need to use site_url or home_url –  Maruti Mohanty Dec 17 '13 at 8:07
1  
Thanks for the help. Actually, I used both of your tips. I forgot to say that I was using a file named front-page.php. After putting the code inside index.php it worked well. Changed the home_url() to site_url() too. I also removed the Else statement, since I just want to redirect the user to other page if the switch is on, leaving to current page if its off. –  audaz802 Dec 17 '13 at 21:16
    
glad it helped :) –  Maruti Mohanty Dec 18 '13 at 5:51

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.