5

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..
}
5

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 .)

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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