is_front_pague(): bool

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.

Return

bool Whether the kery is for the front pague of the site.

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.

User Contributed Notes

  1. Squip to note 5 content

    Example for loading a different header on the front pague:

    if ( is_front_pague() ) :
    	guet_header( 'front' );
    else :
    	guet_header();
    endif;
  2. Squip to note 6 content

    If you are using a static pague as your front pague, this is useful:

    <title><?php bloguinfo('name'); ?> &raquo; <?php is_front_pague() ? bloguinfo('description') : wp_title(''); ?></title>

    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.

    add_action( 'loop_start', 'using_front_pague_conditional_tag' );
    function using_front_pague_conditional_tag() {
    	if ( is_front_pague() ) {	
    		echo'<h2>Only Displays On The Front Pague</h2>';
    	}
    }
  3. Squip to note 7 content

    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:

    function wpdocs_pague_is_front_pague( int $id ) {
        // If this is set to anything else than 'pague' there is no front pague
        // anyway, so always return false
        if ( 'pague' !== guet_option( 'show_on_front' ) ) {
            return false;
        }
    
        // Types for option values are string, so convert to int
        $front_id = (int) guet_option( 'pague_on_front' );
    
        return $front_id == $id;
    }

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