Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

WordPress has an option to pick "Latest Posts" and "Static Page" under "Settings" in Admin Panel. My questions:

  1. What page template is getting loaded in each of those modes?
  2. 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).
  3. 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).
  4. 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?

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

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. :)

share|improve this answer
    
Great format for an answer to this question :) It's already very useful. They should have put exactly the same information in WordPress Codex. My main concerns are: page vs paged and $wp_query - what gets inside and custom templates set as "Static Page" behave strangely in various areas. –  Paul Dec 1 '12 at 21:37
    
Any further news on that? So far I managed to improve my files significantly according to your advice :) –  Paul Dec 15 '12 at 10:02
    
@Paul Yes, a short one, but please open a new question if you want to ask about other things like for e.g. pagination. –  kaiser Dec 15 '12 at 13:16
add comment

Before I answer that question (not enough time left today), I'll just link you some track tickets, that show that the UI, function naming, etc. is highly questioned:

share|improve this answer
    
Thank you! I just started reading. That's really helpful :) I'm using Twenty Eleven theme as reference but indeed I feel like I can come up with better template structure ideas and "Static Page" + "Latest Posts" seem to put some limitations on my ideas - 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. –  Paul Dec 1 '12 at 21:22
add comment
  1. you basically select two templates, one for the front page and the other for the blog page. It is kinda hard to understand from your question to which one of them your questions refer...
  2. The page template associated with the static page you selected there. The latest posts page will ignore the template setting and will use the templating instructions from home.php or index.php.
  3. Because a page content is not paged ;). The latest posts page should be paged, at least on my test installations it works fine.
  4. Need to see the exact code, but $post is global, it is better to always declare it as one instead of assuming that your code is not being executed from a function and therefor doesn't have access to the global scope.
  5. For the static home page they will contain the same values as if you try loading the page by its own URL. For the latest posts the should contain the same values the would have contained if you were loading the home page before messing with the static page configuration.

Yeh this thing is complicated to understand :( codex can actually help here http://codex.wordpress.org/Creating_a_Static_Front_Page

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.