Languages: 한국어 • English • a Static Front Page 日本語 Português do Brasil • (Add your language)
By default, WordPress shows your most recent posts in reverse chronological order on the front page of your site. Many WordPress users want a static front page or splash page as the front page instead. This "static front page" look is common for users desiring static or welcoming information on the front page of the site.
The look and feel of the front page of the site is based upon the choices of the user combined with the features and options of the WordPress Theme.
There are four models for WordPress layout and structure, three that include static front pages.
No matter which layout structure you choose, the process of setting up the static front page in WordPress is basically the same.
There are two steps critical to creating a static front page on your site with WordPress.
The Page assigned as the front page of the site will display the static information you wish readers to know. It may be customized to direct people to welcome or offer instructions, featured content, highlight specific posts, articles, categories, or contributors.
The Page assigned as the blog page (posts page) of the site displays posts in reverse chronological order. Posts set as Sticky Posts will stick to the top of the queue, and navigation and organization of post content is through categories and tags.
Creating a virtual static front page does not require editing or coding of files or templates. Using the default configuration for a "static front page" in WordPress does not remove the sidebar or change the look of the entire site, just the content area.
Please note that the names for the Pages used in these examples are web standardized names. You may choose alternative titles.
To create the static front page, go to the WordPress Administration Panels.
While we are calling this a "static front page," you may edit the content on that web page at any time by editing the "Home" Page.
Developing Theme template files that incorporate the static front page feature requires understanding of the WordPress Template Hierarchy.
On the site front page, WordPress will always use the front-page.php template file, if it exists. If front-page.php does not exist, WordPress will determine which template file to use, depending on the user configuration of 'Settings > Reading ->Front page displays', as follows:
To create a custom site front page template, include either of the following in the Theme:
To create a custom blog posts index template, include the following in the Theme:
Use only the home.php template file for the blog posts index. Do not use a Custom Page Template (such as template-blog.php) for two reasons:
When the site front page is being displayed and 'Settings > Reading ->Front page displays' is set to "Your latest posts", both is_front_page() and is_home() will return true.
If it exists, the front-page.php template file is used on the site's front page regardless of whether 'Settings > Reading ->Front page displays' is set to "A static page" or "Your latest posts," the Theme will need to account for both options, so that the site front page will display either a static page or the blog posts index. There are a few methods to do so.
One way to allow front-page.php to account for both options for 'Settings > Reading ->Front page displays' is to add a conditional inside of front-page.php itself, using get_option( 'show_on_front' ), get_home_template(), and get_page_template().
Method 1: including custom content directly within front-page.php:
if ( 'posts' == get_option( 'show_on_front' ) ) { include( get_home_template() ); } else { // Custom content markup goes here }
Method 2: including any page template:
if ( 'posts' == get_option( 'show_on_front' ) ) { include( get_home_template() ); } else { include( get_page_template() ); }
Another way to allow the site front page to display either a static page/custom content or the blog posts index, without adding conditional code within front-page.php, is to filter frontpage_template, by adding a filter callback to functions.php:
function themeslug_filter_front_page_template( $template ) { return is_home() ? '' : $template; } add_filter( 'frontpage_template', 'themeslug_filter_front_page_template' );
This method causes WordPress to bypass the front-page.php template file altogether when the blog posts index is being displayed.
If the front-page.php template file includes a default WordPress Loop, like so:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); // do something endwhile; else: // no posts found endif;
That loop applies to the post content of the static page assigned to 'Settings > Reading ->Posts page'.
To display custom loops (latest blog posts, custom/featured content, etc.), add secondary loop queries using calls to WP_Query. For example, to show the 3 latest blog posts:
$latest_blog_posts = new WP_Query( array( 'posts_per_page' => 3 ) ); if ( $latest_blog_posts->have_posts() ) : while ( $latest_blog_posts->have_posts() ) : $latest_blog_posts->the_post(); // Loop output goes here endwhile; endif;
Static front pages are not intended to be paged. None of the WordPress Previous / Next page link functions work with a static front page. Pagination on a static front page uses the page query variable, not the paged variable. See the WP_Query for details.