Conditional Tags
- The
is_front_page()
Conditional Tag returnstrue
if you’re on the Front Page (index.php
as fallback orfront-page.php
). - The
is_home()
Conditional Tag returnstrue
if you’re on the Front Page, when you got no static page set as front page, or when you got a static front page and display the Posts Page (home.php
orindex.php
as fallback). - If you got no static front page set under “Settings > Reading”, then both
is_front_page()
andis_home()
will returntrue
forhome.php
,front-page.php
andindex.php
.
Options
- If you got a static front page, then
get_option( 'show_on_front' );
has the valuepage
. - To retrieve the ID for the Front page, you can call
get_page( get_option('page_on_front') )
. - To retrieve the link to the Front page, you can call
get_permalink( get_option('page_on_front') )
. - To retrieve the ID for the Posts page, you can call
get_page( get_option('page_for_posts') )
. - To retrieve the link to the Posts page, you can call
get_permalink( get_option('page_for_posts') )
. - If you have a child theme, then
home.php
will not act as fallback forfront-page.php
. - To retrieve custom values from the Front page, you can call
get_post_custom('page_on_front') )
. - To retrieve custom values from the Posts page, you can call
get_post_custom('page_for_posts') )
.
… the list of AAARGH!!s goes on and on.
especially when user tries to set custom template as “Static Page” – pagination stops working unless I use page and custom fields stop working unless I create new WP Query.
From a comment of the OP to another answer
As you can see in this diagram, it’s not that easy to get around what to use where. The problem is that there’re functions that intercept the main $wp_query
object, others that copy over the contents of the $wp_the_query
object, etc. And than there’re those that only work with the main $wp_query
object. I know this is no full answer to your pagination question, but this also has never been the question. 🙂