Blogvaria

This page is brought to you by Blogvaria (http://blog.evaria.com).

To obtain more information, ask questions and interact please visit our website.

Back to Blogvaria landing page
Feedback
Subscribe
   
Blogvaria

 

The personal pages

Static Front and Post pages

TrackBack | Filed by under WordPress | Post popularity 7%

Static front and post pages were introduced in WordPress 2.1. For some reason I could not get this working at all and realised that the template directory most likely needed some fresh code. After a little “Googleing” I found out that WordPress by default are trying to pull home.php before index.php when entering your blog (WP installation). Therefore a “hack” should be implemented in this template file.

Creating the necessary code

Create a file called home.php and add the following code inside:

<?php
# Get the page ID's for the front and post pages
$intHome = get_option('page_on_front');
$intPage = get_option('page_for_posts');

# Get the current URI
$strWPPage = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
# Get your blogs front page URI
$strWPHome = get_bloginfo('wpurl')."/";

# Displays the static front page if set under options --> reading
if (is_home() && !empty($intHome) && $strWPPage == $strWPHome) :

	query_posts('page_id='.$intHome);
	include (TEMPLATEPATH . '/page.php');

# Displays the static posts page if set under options --> reading
elseif (is_home() && !empty($intPage)) :

	query_posts('page_id='.$intPage);
	include (TEMPLATEPATH . '/index.php');

else :

	include (TEMPLATEPATH . '/index.php');

endif;
?>

Adding the new code

Simply upload the new file to your template directory using your favourite FTP client. Finalize the procedure by logging into your WP admin and click Options then Reading and adjust the Static pages options listed the way you want.

Hint: By adding a blank page called e.g. “Blog” you would get a very logical link to your static post listings page…

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • BlinkList
  • blogmarks
  • del.icio.us
  • De.lirio.us
  • digg
  • Furl
  • NewsVine
  • Netscape
  • Reddit
  • Spurl
  • SphereIt
  • Technorati
  • YahooMyWeb
  • DZone
  • feedmelinks
  • Linkter
  • Ma.gnolia
  • Slashdot
  • StumbleUpon
  • TailRank
  • co.mments

Comments are closed.

Akismet has protected Blogvaria from 122,199 spam comments. Design by Evaria.com. Powered by WordPress.
Our beloved and trusted server has rendered 67 pages so far today, an amazing 2.047 pages yesterday
and even more astonishingly 244.988 pages since 19 Feb 2012 alone without dropping a byte nor a pixel.

Close
E-mail It