WordPress has an option to pick “Latest Posts” and “Static Page” under “Settings” in Admin Panel. My questions:
- What page template is getting loaded in each of those modes?
- Why
paged
stops working and page
starts working when I select “Static Page” – paged
works, however, when I create new page template with new WP Query and page
doesn’t work (this is about WP Query – I think that everyone knows what I’m talking about – it’s pagination).
- It looks like
get_post_meta($post->ID, "my_custom_field_name", true)
stops working when I select custom page template as “Static Page” but the same thing works when I use it via standard “View Page” in Admin Panel (I haven’t tried global $post
, yet).
- I think that all my above questions are related to what gets inside
$wp_query
and $post
in each of those modes.
I just don’t get these two options 🙂 Can someone provide me some guidance or resources where I could find out more about it?
Conditional Tags
- The
is_front_page()
Conditional Tag returns true
if you’re on the Front Page (index.php
as fallback or front-page.php
).
- The
is_home()
Conditional Tag returns true
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
or index.php
as fallback).
- If you got no static front page set under “Settings > Reading”, then both
is_front_page()
and is_home()
will return true
for home.php
, front-page.php
and index.php
.
Options
- If you got a static front page, then
get_option( 'show_on_front' );
has the value page
.
- 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 for front-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. 🙂