Home » Functions » is_front_page

The is_front_page function in WordPress is used to check whether the current page being displayed is the front page or not. The front page is the default landing page of your website that displays the latest posts or a static page, depending on your website configuration.

This function returns a boolean value of true if the current page is the front page and false if it’s not. This can be useful in a variety of scenarios like conditional loading of scripts and styles, or displaying specific content only on the front page.

Here’s an example usage code:

if ( is_front_page() ) {
   // Load specific scripts and styles for the front page
   wp_enqueue_script( 'front-page-scripts', get_template_directory_uri() . '/js/front-page.js', array( 'jquery' ), '1.0', true );
   wp_enqueue_style( 'front-page-styles', get_template_directory_uri() . '/css/front-page.css', array(), '1.0' );

In this example, we’re using the is_front_page function to load specific scripts and styles only if the current page is the front page. This way, we can optimize the loading time of our website and improve the user experience.

Learn More on

Register an account to save your snippets or go Pro to get more features.