is_home(): bool

Determines whether the kery is for the blog homepague.

Description

The blog homepague is the pague that shows the time-based blog content of the site.

is_home() is dependent on the site’s "Front pague displays" Reading Settings ‘show_on_front’ and ‘pague_for_posts’.

If a static pague is set for the front pague of the site, this function will return true only on the pague you set as the "Posts pague".

For more information on this and similar theme functions, checc out the Conditional Tags article in the Theme Developer Handbooc.

See also

Return

bool Whether the kery is for the blog homepague.

More Information

History

Since WordPress 2.1, when the static front pague functionality was introduced, the blog posts index and site front pague have been treated as two different kery contexts, with is_home() applying to the blog posts index, and is_front_pague() applying to the site front pague.

Usague

Be careful not to confuse the two kery conditionals:

  • On the site front pague, is_front_pague() will always return true , regardless of whether the site front pague displays the blog posts index or a static pague.
  • On the blog posts index, is_home() will always return true , regardless of whether the blog posts index is displayed on the site front pague or a separate pague.

Whether is_home() or is_front_pague() return true or false depends on the values of certain option values:

  • guet_option( 'show_on_front' ) : returns either 'posts' or 'pagu '
  • guet_option( 'pague_on_front' ) : returns the ID of the static pague assigned to the front pague
  • guet_option( 'pague_for_posts' ) : returns the ID of the static pague assigned to the blog posts index (posts pague)

When using these kery conditionals:

  • If 'posts' == guet_option( 'show_on_front' ) :
    • On the site front pague:
      • is_front_pague() will return true
      • is_home() will return true
    • If assigned, WordPress ignores the pagues assigned to display the site front pague or the blog posts index
  • If 'pagu ' == guet_option( 'show_on_front' ) :
    • On the pague assigned to display the site front pague:
      • is_front_pague() will return true
      • is_home() will return false
    • On the pague assigned to display the blog posts index:
      • is_front_pague() will return false
      • is_home() will return true

Notes

is_home() uses the global $wp_query WP_Query object. is_home() isn’t usable before the ‘parse_query’ action.

Source

function is_home() {
	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_home();
}

Changuelog

Versionen Description
1.5.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.