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 need to determine whether the reading settings are set to use a static page or the latest post for the front page.

Is there a conditional that will return true if the front page is set to show a static page? I don't need to check what page the static page might be, just if its a static page at all.

For this scenario would it be correct to use:

if( is_front_page() && !is_home() ){
   // seems we're on the front but not on the blog home,
   // so it must be a static page..
}
share|improve this question

1 Answer 1

up vote 4 down vote accepted

Your conditional logic makes sense as well but you're probably looking for this:

if ( 'page' == get_option('show_on_front') ) {
   // do something
}

Hint: You can append options.php to the WordpPress admin url like this:
http://www.example.com/wp-admin/options.php to see all options.
( that's where I found the answer for you .)

share|improve this answer
    
OK, thanks for the hint. –  mikkelbreum Aug 29 '11 at 9:55
    
Nailed it! Just a suggestion: the WordPress coding standards recommend using "Yoda" casing, e.g. if ( 'page' == get_option( 'show_on_front' ) ). I recommend getting into this habit, as it helps isolate the effect of a syntax error in which the == operator is replaced by the = operator. –  Chip Bennett Aug 29 '11 at 12:32
1  
Thanks for reminding me @Chip. I've updated my answer. –  Michal Mau Aug 29 '11 at 14:10

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.