How to check if your main blog page is being displayed.

March 12th, 2009 Posted in Wordpress

Difficulty Level:


Sometimes it is usefull to display other information on your main blog page. WordPress provides a conditional tag called “is_home()”. This tag detects if you are on the main blog page, so you are able to display other or more information on the main blog page.

  1. <?php
  2. // Check if you are on the main page
  3. if (is_home()){
  4. // get all catogery id's
  5. $catIDs = get_all_category_ids();
  6. // get all post with the first category id
  7. query_posts('cat=' . $catIDs[0]);
  8. }
  9. ?>


  1. We use the conditional tag “is_home()” to detect if we are on the main page.
  2. Then we get all category id’s.
  3. We look for posts with the first category id.

You can download this example here.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • MisterWong
  • Y!GG
  • Webnews
  • Digg
  • StumbleUpon
  • Reddit

Comments are closed.

My-Guide Interessante Guides: K├╝ndigungFitnessSparenLinuxEinb├╝rgerungst..