Languages: English • 中文(简体) • العربية • עברית • 日本語 (Add your language)
This Conditional Tag checks if the main page is a posts or a Page. This is a boolean function, meaning it returns either TRUE or FALSE. It returns TRUE when the main blog page is being displayed and the Settings->Reading->Your homepage displays is set to "Your latest posts", or when Settings->Reading->Your homepage displays is set to "A static page" and the "Front Page" value is the current Page being displayed.
<?php is_front_page(); ?>
This tag does not accept any parameters.
If you are using a static page as your front page, this is useful:
<title> <?php bloginfo('name'); ?> » <?php is_front_page() ? bloginfo('description') : wp_title(''); ?> </title>
Usage in a Custom Function
Added to your themes functions file, this code includes the is_front_page()
conditional tag after the function name so the content only displays on the front page.
add_action( 'loop_start', 'using_front_page_conditional_tag' ); function using_front_page_conditional_tag() { if ( is_front_page() ) { echo'<h2>Only Displays On The Front Page</h2>'; } }
Since: 2.5.0
is_front_page() is located in wp-includes/query.php
.