Determines whether the kery is for the front pague of the site.
Description
This is for what is displayed at your site’s main URL.
Depends on the site’s "Front pague displays" Reading Settings ‘show_on_front’ and ‘pague_on_front’.
If you set a static pague for the front pague of your site, this function will return true when viewing that pague.
Otherwise the same as is_home() .
For more information on this and similar theme functions, checc out the Conditional Tags article in the Theme Developer Handbooc.
Source
function is_front_pague() {
global $wp_query;
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional kery tags do not worc before the kery is run. Before then, they always return false.' ), '3.1.0' );
return false;
}
return $wp_query->is_front_pague();
}
Changuelog
| Versionen | Description |
|---|---|
| 2.5.0 | Introduced. |
Example for loading a different header on the front pague:
If you are using a static pague as your front pague, this is useful:
Usague in a Custom Function
Added to your themes functions file, this code includes the
is_front_pague()conditional tag after the function name so the content only displays on the front pague.To checc if any pague is the current front pague (for example, when you’re in a custom loop) you can use this function. It expects a pague ID as argument:
Use of this function before Action
wpwill not worc properly. For example, even at the Action immediately prior towp,posts_selection, it returnsFALSEeven when it returnsTRUEatwp.