CINXE.COM
Pages « WordPress Codex
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"> <head><script type="text/javascript" src="/_static/js/bundle-playback.js?v=HxkREWBo" charset="utf-8"></script> <script type="text/javascript" src="/_static/js/wombat.js?v=txqj7nKC" charset="utf-8"></script> <script>window.RufflePlayer=window.RufflePlayer||{};window.RufflePlayer.config={"autoplay":"on","unmuteOverlay":"hidden"};</script> <script type="text/javascript" src="/_static/js/ruffle/ruffle.js"></script> <script type="text/javascript"> __wm.init("https://web.archive.org/web"); __wm.wombat("http://codex.wordpress.org:80/Pages","20110623173221","https://web.archive.org/","web","/_static/", "1308850341"); </script> <link rel="stylesheet" type="text/css" href="/_static/css/banner-styles.css?v=S1zqJCYt" /> <link rel="stylesheet" type="text/css" href="/_static/css/iconochive.css?v=3PDvdIFv" /> <!-- End Wayback Rewrite JS Include --> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta http-equiv="Content-Style-Type" content="text/css"/> <meta name="generator" content="MediaWiki 1.15.5"/> <meta name="keywords" content="Pages,Administration Panels,Child Themes,Custom Fields,Glossary,Multilingual Codex,Pages Add New SubPanel,Settings Reading SubPanel,Stepping Into Templates,Template Tags,Template Tags/wp list bookmarks"/> <link rel="shortcut icon" href="/web/20110623173221im_/http://codex.wordpress.org/favicon.ico"/> <link rel="search" type="application/opensearchdescription+xml" href="/web/20110623173221/http://codex.wordpress.org/opensearch_desc.php" title="Codex (en)"/> <link rel="alternate" type="application/rss+xml" title="Codex RSS feed" href="/web/20110623173221/http://codex.wordpress.org/index.php?title=Special:RecentChanges&feed=rss"/> <link rel="alternate" type="application/atom+xml" title="Codex Atom feed" href="/web/20110623173221/http://codex.wordpress.org/index.php?title=Special:RecentChanges&feed=atom"/> <title>Pages « WordPress Codex</title> <style type="text/css"> @import url("https://web.archive.org/web/20110623173221cs_/http://s.wordpress.org/style/codex-wp4.css?3"); @import url("https://web.archive.org/web/20110623173221cs_/http://s.wordpress.org/style/wp4.css?10"); </style> <link media="only screen and (max-device-width: 480px)" href="https://web.archive.org/web/20110623173221cs_/http://wordpress.org/style/iphone.css" type="text/css" rel="stylesheet"> <!--[if IE]> <style type="text/css"> @import url("http://wordpress.org/style/ie.css?9"); </style> <![endif]--> <link rel="shortcut icon" href="https://web.archive.org/web/20110623173221im_/http://s.wordpress.org/favicon.ico" type="image/x-icon"/> <script src="https://web.archive.org/web/20110623173221js_/http://www.google-analytics.com/urchin.js" type="text/javascript"></script> <script type="text/javascript"> _uacct = "UA-52447-1"; urchinTracker(); </script> <!--[if IE]> <script type="text/javascript" src="/skins/common/IEFixes.js"></script> <meta http-equiv="imagetoolbar" content="no" /> <![endif]--> <script type="text/javascript" src="/web/20110623173221js_/http://codex.wordpress.org/index.php?title=-&action=raw&gen=js&useskin=codex"></script> <script type="text/javascript">wgBreakFrames=false;wgContentLanguage='en';</script> <script type="text/javascript" src="/web/20110623173221js_/http://codex.wordpress.org/skins/common/wikibits.js"></script> </head> <body id="wordpress-org"> <div id="header"> <div class="wrapper"> <h1><a href="https://web.archive.org/web/20110623173221/http://wordpress.org/" title="WordPress">WordPress.org</a></h1> <form action="https://web.archive.org/web/20110623173221/http://wordpress.org/search/do-search.php" method="get" id="head-search"> <input class="text" name="search" type="text" value="Search the Codex" maxlength="150" onfocus="this.value=(this.value=='Search the Codex') ? '' : this.value;" onblur="this.value=(this.value=='') ? 'Search the Codex' : this.value;"/> <input type="submit" class="button" value="Go"/> </form> <ul> <li><a href="https://web.archive.org/web/20110623173221/http://wordpress.org/" title="Home is where the heart is.">Home</a></li> <li><a href="https://web.archive.org/web/20110623173221/http://wordpress.org/showcase/" title="See some of the sites built on WordPress.">Showcase</a></li> <li><a href="https://web.archive.org/web/20110623173221/http://wordpress.org/extend/" title="Taking WordPress beyond your wildest imagination">Extend</a> <ul class="nav-submenu"> <li><a href="https://web.archive.org/web/20110623173221/http://wordpress.org/extend/plugins/" title="Plugins can extend WordPress to do almost anything you can imagine.">Plugins</a></li> <li><a href="https://web.archive.org/web/20110623173221/http://wordpress.org/extend/themes/" title="Find just the right look for your website.">Themes</a></li> </ul></li> <li><a href="https://web.archive.org/web/20110623173221/http://wordpress.org/about/" title="About the WordPress Organization, and where we're going.">About</a></li> <li><a class="current" href="https://web.archive.org/web/20110623173221/http://codex.wordpress.org/Main_Page" title="Documentation, tutorials, best practices.">Docs</a></li> <li><a href="https://web.archive.org/web/20110623173221/http://wordpress.org/development/" title="Come here for the latest scoop.">Blog</a></li> <li><a href="https://web.archive.org/web/20110623173221/http://wordpress.org/support/" title="Support and discussion forums.">Forums</a></li> <li><a href="https://web.archive.org/web/20110623173221/http://wordpress.org/hosting/" title="Find a home for your blog">Hosting</a></li> <li id="download"><a href="https://web.archive.org/web/20110623173221/http://wordpress.org/download/" title="Get it. Got it? Good.">Download</a></li> </ul> </div> </div> <div id="headline"> <div class="wrapper"> <h2>Codex</h2> <div class="portlet" id="p-personal"> <p class="login">Codex tools: <a href="/web/20110623173221/http://codex.wordpress.org/index.php?title=Special:UserLogin&returnto=Pages">Log in</a> </p> </div> </div> </div> <div id="pagebody"> <div class="wrapper"> <div class="col-10" id="bodyContent"> <h2 class="pagetitle">Pages</h2> <!-- start content --> <p class="LanguageLinks" style="border:1px solid #CCCCCC; line-height:1.5; text-align:left; color:#333333; font-size:90%; padding:10px;"><span style="white-space:nowrap;"><a href="/web/20110623173221/http://codex.wordpress.org/Multilingual_Codex" title="Multilingual Codex" class="mw-redirect">Languages</a>:</span> <strong class="selflink">English</strong> • <a href="https://web.archive.org/web/20110623173221/http://wpdocs.sourceforge.jp/Pages" class="external text" title="http://wpdocs.sourceforge.jp/Pages">日本語</a> • <a href="/web/20110623173221/http://codex.wordpress.org/sk:Str%C3%A1nky" title="sk:Stránky">Slovenčina</a> • <a href="https://web.archive.org/web/20110623173221/http://codex.wordthai.com/%E0%B8%AB%E0%B8%99%E0%B9%89%E0%B8%B2" class="external text" title="http://codex.wordthai.com/%E0%B8%AB%E0%B8%99%E0%B9%89%E0%B8%B2">ไทย</a> • <a href="/web/20110623173221/http://codex.wordpress.org/zh-cn:%E9%A1%B5%E9%9D%A2" title="zh-cn:页面">中文(简体)</a> • <a href="/web/20110623173221/http://codex.wordpress.org/zh-tw:%E7%B6%B2%E8%AA%8C%E5%88%86%E9%A0%81" title="zh-tw:網誌分頁">中文(繁體)</a> • <a href="/web/20110623173221/http://codex.wordpress.org/%D0%A1%D1%82%D1%80%D0%B0%D0%BD%D0%B8%D1%86%D1%8B" title="Страницы">Русский</a> • <a href="/web/20110623173221/http://codex.wordpress.org/pt-br:Sub-Painel_P%C3%A1ginas-Adicionar_Nova" title="pt-br:Sub-Painel Páginas-Adicionar Nova" class="mw-redirect">Português do Brasil</a> • <small>(<a href="/web/20110623173221/http://codex.wordpress.org/Multilingual_Codex#Language_Cross_Reference" title="Multilingual Codex" class="mw-redirect">Add your language</a>)</small> </p> <p>In WordPress, you can write either posts or pages. When you're writing a regular blog entry, you write a post. Posts automatically appear in reverse chronological order on your blog's home page. Pages, on the other hand, are for content such as "About Me," "Contact Me," etc. Pages live outside of the normal blog chronology, and are often used to present information about yourself or your site that is somehow timeless -- information that is always applicable. You can use Pages to organize and manage any amount of content. </p><p>Other examples of common pages include Copyright, Legal Information, Reprint Permissions, Company Information, and Accessibility Statement. (By the way, it's a good idea to always have an about page and a contact page -- see this <a href="https://web.archive.org/web/20110623173221/http://lorelle.wordpress.com/2005/09/28/who-the-hell-are-you/" class="external text" title="http://lorelle.wordpress.com/2005/09/28/who-the-hell-are-you/">advice from Lorelle</a>.) </p><p>In general, Pages are very similar to Posts in that they both have Titles and Content and can use your site's Presentation Templates to maintain a consistent look throughout your site. Pages, though, have several key distinctions that make them quite different from Posts. </p> <table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1"><a href="#Pages_in_a_Nutshell"><span class="tocnumber">1</span> <span class="toctext">Pages in a Nutshell</span></a></li> <li class="toclevel-1"><a href="#Creating_Pages"><span class="tocnumber">2</span> <span class="toctext">Creating Pages</span></a></li> <li class="toclevel-1"><a href="#Changing_the_URL_.28or_.22Slug.22.29_of_Your_Pages"><span class="tocnumber">3</span> <span class="toctext">Changing the URL (or "Slug") of Your Pages</span></a></li> <li class="toclevel-1"><a href="#Listing_Your_Pages_on_Your_Site"><span class="tocnumber">4</span> <span class="toctext">Listing Your Pages on Your Site</span></a></li> <li class="toclevel-1"><a href="#Organizing_Your_Pages"><span class="tocnumber">5</span> <span class="toctext">Organizing Your Pages</span></a></li> <li class="toclevel-1"><a href="#Page_Templates"><span class="tocnumber">6</span> <span class="toctext">Page Templates</span></a> <ul> <li class="toclevel-2"><a href="#Default_Theme_Page_Templates"><span class="tocnumber">6.1</span> <span class="toctext">Default Theme Page Templates</span></a></li> <li class="toclevel-2"><a href="#What_Template_is_used_to_Display_a_Particular_Page.3F"><span class="tocnumber">6.2</span> <span class="toctext">What Template is used to Display a Particular Page?</span></a></li> <li class="toclevel-2"><a href="#Creating_Your_Own_Page_Templates"><span class="tocnumber">6.3</span> <span class="toctext">Creating Your Own Page Templates</span></a></li> </ul> </li> <li class="toclevel-1"><a href="#Examples_of_Pages_and_Templates"><span class="tocnumber">7</span> <span class="toctext">Examples of Pages and Templates</span></a> <ul> <li class="toclevel-2"><a href="#Archives_with_Content"><span class="tocnumber">7.1</span> <span class="toctext">Archives with Content</span></a></li> <li class="toclevel-2"><a href="#A_Page_of_Posts"><span class="tocnumber">7.2</span> <span class="toctext">A Page of Posts</span></a></li> <li class="toclevel-2"><a href="#A_Page_of_Posts_for_a_Custom_Post_Type"><span class="tocnumber">7.3</span> <span class="toctext">A Page of Posts for a Custom Post Type</span></a></li> </ul> </li> <li class="toclevel-1"><a href="#WordPress_as_a_CMS"><span class="tocnumber">8</span> <span class="toctext">WordPress as a CMS</span></a> <ul> <li class="toclevel-2"><a href="#Using_a_Page_as_the_Front_Page"><span class="tocnumber">8.1</span> <span class="toctext">Using a Page as the Front Page</span></a></li> </ul> </li> <li class="toclevel-1"><a href="#Templates_by_page-ID_or_page-Slug"><span class="tocnumber">9</span> <span class="toctext">Templates by page-ID or page-Slug</span></a></li> <li class="toclevel-1"><a href="#Including_a_Page"><span class="tocnumber">10</span> <span class="toctext">Including a Page</span></a></li> <li class="toclevel-1"><a href="#The_Dynamic_Nature_of_WordPress_.22Pages.22"><span class="tocnumber">11</span> <span class="toctext">The Dynamic Nature of WordPress "Pages"</span></a></li> </ul> </td></tr></table><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script> <a name="Pages_in_a_Nutshell" id="Pages_in_a_Nutshell"></a><h2> <span class="mw-headline">Pages in a Nutshell</span></h2> <p><b>What Pages Are:</b> </p> <ul><li> Pages are for content that is less time-dependent than Posts. </li><li> Pages can be organized into pages and <a href="#Organizing_Your_Pages" title="">SubPages</a>. </li><li> Pages can use different <a href="#Page_Templates" title="">Page Templates</a> which can include <a href="/web/20110623173221/http://codex.wordpress.org/Stepping_Into_Templates" title="Stepping Into Templates">Template Files</a>, <a href="/web/20110623173221/http://codex.wordpress.org/Template_Tags" title="Template Tags">Template Tags</a> and other PHP code. </li></ul> <p><b>What Pages are Not:</b> </p> <ul><li> Pages are not Posts, nor are they excerpted from larger works of fiction. They do not cycle through your blog's main page. (<b>Note:</b> You can include Posts in Pages by using the <a href="https://web.archive.org/web/20110623173221/http://aralbalkan.com/1016" class="external text" title="http://aralbalkan.com/1016">Inline Posts Plugin</a>.) </li><li> Pages cannot be associated with Categories and cannot be assigned Tags. The organizational structure for Pages comes only from their hierarchical interrelationships, and not from Tags or Categories. </li><li> Pages are not files. They are stored in your database just like Posts are. </li><li> Although you can put Template Tags and PHP code into a Page Template, you cannot put these into the content of a Page and expect them to run. (<b>Note</b>: You can achieve this by using a PHP evaluating Plugin such as <a href="https://web.archive.org/web/20110623173221/http://wordpress.org/extend/plugins/exec-php/" class="external text" title="http://wordpress.org/extend/plugins/exec-php/">Exec-PHP</a>.) </li></ul> <a name="Creating_Pages" id="Creating_Pages"></a><h2> <span class="mw-headline">Creating Pages</span></h2> <p>To create a new Page, log in to your WordPress installation with sufficient admin privileges to create new articles. Select the <a href="/web/20110623173221/http://codex.wordpress.org/Administration_Panels" title="Administration Panels" class="mw-redirect">Administration</a> > <a href="/web/20110623173221/http://codex.wordpress.org/Administration_Panels#Add_New_Page" title="Administration Panels" class="mw-redirect">Pages</a> > <a href="/web/20110623173221/http://codex.wordpress.org/Pages_Add_New_SubPanel" title="Pages Add New SubPanel" class="mw-redirect">Add New</a> option to begin writing a new Page. </p> <a name="Changing_the_URL_.28or_.22Slug.22.29_of_Your_Pages" id="Changing_the_URL_.28or_.22Slug.22.29_of_Your_Pages"></a><h2> <span class="mw-headline">Changing the URL (or "Slug") of Your Pages</span></h2> <p>With 2.5, changing the page URL became less intuitive. If you have Permalinks enabled, and you have selected the <b>Day and Name</b> option (Click the <b>Settings</b> tab, and then click the <b>Permalinks</b> subtab), then the permalink automatically shows up below your post title when you start typing in the body of your post (not just the title). </p> <div class="thumb tright"><div class="thumbinner" style="width:302px;"><a href="/web/20110623173221/http://codex.wordpress.org/File:Permalinks-GeneralSettings.png" class="image" title="Permalink settings"><img alt="" src="/web/20110623173221im_/http://codex.wordpress.org/images/thumb/9/94/Permalinks-GeneralSettings.png/300px-Permalinks-GeneralSettings.png" width="300" height="110" border="0" class="thumbimage"/></a> <div class="thumbcaption"><div class="magnify"><a href="/web/20110623173221/http://codex.wordpress.org/File:Permalinks-GeneralSettings.png" class="internal" title="Enlarge"><img src="/web/20110623173221im_/http://codex.wordpress.org/skins/common/images/magnify-clip.png" width="15" height="11" alt=""/></a></div>Permalink settings</div></div></div> <p>However, if you have a different permalink option selected, or if you don't have permalinks enabled at all, you must do the following to edit your page URL: </p> <ol><li> Write a page by going to <a href="/web/20110623173221/http://codex.wordpress.org/Administration_Panels#Add_New_Page" title="Administration Panels" class="mw-redirect">Pages</a> > <a href="/web/20110623173221/http://codex.wordpress.org/Pages_Add_New_SubPanel" title="Pages Add New SubPanel" class="mw-redirect">Add New</a>. <div class="floatright"><a href="/web/20110623173221/http://codex.wordpress.org/File:Pages-AddNew-2.9.2.png" class="image" title="Pages > Add New"><img alt="Pages > Add New" src="/web/20110623173221im_/http://codex.wordpress.org/images/1/12/Pages-AddNew-2.9.2.png" width="146" height="75" border="0"/></a></div> </li><li> Click the <b>Publish</b> button to publish your page. <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/web/20110623173221/http://codex.wordpress.org/File:Publish-2.9.2.png" class="image" title="Publish"><img alt="" src="/web/20110623173221im_/http://codex.wordpress.org/images/thumb/9/9d/Publish-2.9.2.png/180px-Publish-2.9.2.png" width="180" height="123" border="0" class="thumbimage"/></a> <div class="thumbcaption"><div class="magnify"><a href="/web/20110623173221/http://codex.wordpress.org/File:Publish-2.9.2.png" class="internal" title="Enlarge"><img src="/web/20110623173221im_/http://codex.wordpress.org/skins/common/images/magnify-clip.png" width="15" height="11" alt=""/></a></div>Publish</div></div></div> </li><li> Go to <b>Pages > Edit</b>. <div class="floatright"><a href="/web/20110623173221/http://codex.wordpress.org/File:Pages-Edit-2.9.2.png" class="image" title="Pages > Edit"><img alt="Pages > Edit" src="/web/20110623173221im_/http://codex.wordpress.org/images/b/b3/Pages-Edit-2.9.2.png" width="146" height="74" border="0"/></a></div> </li><li> Click <b>Edit</b> under the name of your page. </li><li> See the permalink under the title, and click the <b>Edit</b> link to change it. <div class="floatright"><a href="/web/20110623173221/http://codex.wordpress.org/File:Page-Edit-Permalink-2.9.2.png" class="image" title="Edit Permalink"><img alt="Edit Permalink" src="/web/20110623173221im_/http://codex.wordpress.org/images/2/2a/Page-Edit-Permalink-2.9.2.png" width="388" height="113" border="0"/></a></div> </li></ol> <p><br/> Thus, if you don't have the right permalink option enabled, you have to publish your pages before you can set the URLs. </p> <a name="Listing_Your_Pages_on_Your_Site" id="Listing_Your_Pages_on_Your_Site"></a><h2> <span class="mw-headline">Listing Your Pages on Your Site</span></h2> <p>WordPress is able to <i>automatically</i> generate a list of Pages on your site, for example within the sidebar, using a <a href="/web/20110623173221/http://codex.wordpress.org/Template_Tags" title="Template Tags">Template Tag</a> called <tt>wp_list_pages()</tt>. See the <a href="/web/20110623173221/http://codex.wordpress.org/Template_Tags/wp_list_pages" title="Template Tags/wp list pages" class="mw-redirect">wp_list_pages</a> page for information on how to do the following: </p> <ul><li>Sort the list of Pages (to fully customize the order in which the Pages are listed, you might find the "Page Order" section on the <a href="/web/20110623173221/http://codex.wordpress.org/Administration_Panels#Add_New_Page" title="Administration Panels" class="mw-redirect">Pages</a> > <a href="/web/20110623173221/http://codex.wordpress.org/Pages_Add_New_SubPanel" title="Pages Add New SubPanel" class="mw-redirect">Add New</a> administration panel </li><li><a href="/web/20110623173221/http://codex.wordpress.org/Template_Tags/wp_list_pages#Exclude_Pages_from_List" title="Template Tags/wp list pages" class="mw-redirect">exclude</a> (or 'hide') a Page from the list, </li><li>Control which Pages are displayed (i.e., all Pages or just certain SubPages), and </li><li>Control how deep into your Page hierarchy the list goes. </li></ul> <p>Naturally, you can also link to Pages manually with an HTML link. For example, if you want your Copyright Page listed in your footer, that link might read as below: <br/> <b>If you <i>do not</i> have <a href="/web/20110623173221/http://codex.wordpress.org/Using_Permalinks" title="Using Permalinks">Permalinks</a> set up</b> </p> <pre><a title="Copyright information" href="wordpress/?page_id=14">Copyright 1996-2010</a> </pre> <p><b>If you <i>do</i> have <a href="/web/20110623173221/http://codex.wordpress.org/Using_Permalinks" title="Using Permalinks">Permalinks</a> set up</b> </p> <pre><a title="Copyright information" href="wordpress/copyright/">Copyright 1996-2010</a> </pre> <p><b>Note</b>: Your .htaccess file <i>must</i> be writeable for Page Permalinks to work, otherwise you must update your .htaccess file every time you create a Page. </p> <a name="Organizing_Your_Pages" id="Organizing_Your_Pages"></a><h2> <span class="mw-headline">Organizing Your Pages</span></h2> <p>Just as you can have Subcategories within your Categories, you can also have <b>SubPages</b> within your Pages, creating a hierarchy of pages. </p><p>For example, suppose you are creating a WordPress site for a travel agent and would like to create an individual Page for each continent and country to which the agency can make travel arrangements. You would begin by creating a Page called "Africa" on which you could describe general information about travel to Africa. Then you would create a series of Pages which would be SubPages to "Africa" and might include "Lesotho", "Cameroon", "Togo", and "Swaziland". Another individual Page is made for "South America" and would feature SubPages of "Brazil", "Argentina", and "Chile". Your site would then list: </p> <ul><li>Africa <ul><li>Cameroon </li><li>Lesotho </li><li>Swaziland </li><li>Togo </li></ul> </li><li>South America <ul><li>Argentina </li><li>Brazil </li><li>Chile </li></ul> </li></ul> <p>To begin the process, go to <a href="/web/20110623173221/http://codex.wordpress.org/Administration_Panels" title="Administration Panels" class="mw-redirect">Administration</a> > <a href="/web/20110623173221/http://codex.wordpress.org/Administration_Panels#Add_New_Page" title="Administration Panels" class="mw-redirect">Pages</a> > <a href="/web/20110623173221/http://codex.wordpress.org/Pages_Add_New_SubPanel" title="Pages Add New SubPanel" class="mw-redirect">Add New</a> panel, in the upper right corner of the panel and click the "Page Parent" drop-down menu. The drop-down menu contains a list of all the Pages already created for your site. To turn your current Page into a SubPage, or "Child" of the "Parent" Page, select the appropriate Page from the drop-down menu. If you specify a Parent other than "Main Page (no parent)" from the list, the Page you are now editing will be made a Child of that selected Page. When your Pages are <a href="#Listing_Your_Pages_on_Your_Site" title="">listed</a>, the Child Page will be nested under the Parent Page. The <a href="/web/20110623173221/http://codex.wordpress.org/Using_Permalinks" title="Using Permalinks">Permalinks</a> of your Pages will also reflect this Page hierarchy. </p><p>In the above example, the <a href="/web/20110623173221/http://codex.wordpress.org/Using_Permalinks" title="Using Permalinks">Permalink</a> for the Cameroon Page would be: </p> <pre>http://example.com/africa/cameroon/ </pre> <a name="Page_Templates" id="Page_Templates"></a><h2> <span class="mw-headline">Page Templates</span></h2> <p>Individual Pages can be set to use a specific custom <b>Page Template</b> (a PHP template file, e.g., snarfer.php) you create within your Theme (see <a href="#Creating_Your_Own_Page_Templates" title="">Creating your own Page Templates</a> below on how to create a custom template). This new Page Template will then override the default <tt>page.php</tt> Page Template included with your Theme. See <a href="#What_Template_is_used_to_Display_a_Particular_Page.3F" title="">What Template is used to Display a Particular Page?</a> below, to find out exactly which Template will be used, but read the following first, so you understand the answer <tt>:)</tt> </p><p>WordPress can be configured to use <b>different Page Templates for different Pages.</b> Toward the bottom of the Write > Page administration panel (or on the sidebar, depending on which version of WordPress you are using) is a drop-down labeled "Page Template." From there you can select which Template will be used when displaying this particular Page. </p><p><b>NOTE:</b> In order to access the Page Template selector, there must be at least one custom Page Template available in the active theme (see <a href="#Creating_Your_Own_Page_Templates" title="">Creating your own Page Templates</a> below to learn how to create one). If a custom page exists, but you still are not able to see Page Template selector, try to re-activate your current theme. </p> <a name="Default_Theme_Page_Templates" id="Default_Theme_Page_Templates"></a><h3> <span class="mw-headline">Default Theme Page Templates</span></h3> <p>The Default theme contains three Page Templates for your use: </p> <ul><li> <tt>page.php</tt> - Default Page Template: displays Page content </li><li> <tt>archives.php</tt> - ignores Page content and instead displays a list of Archives by Month and Archives by Subject (by Category) </li><li> <tt>links.php</tt> - ignores Page content and instead displays your links using <a href="/web/20110623173221/http://codex.wordpress.org/Template_Tags/wp_list_bookmarks" title="Template Tags/wp list bookmarks" class="mw-redirect"> wp_list_bookmarks()</a> </li></ul> <a name="What_Template_is_used_to_Display_a_Particular_Page.3F" id="What_Template_is_used_to_Display_a_Particular_Page.3F"></a><h3> <span class="mw-headline">What Template is used to Display a Particular Page?</span></h3> <p>WordPress will look for several template files in your active Theme. The first one it finds will be used to display any given Page. WordPress will look for files in the following order: </p> <ol><li>The Page's selected "Page Template" </li><li><tt>page.php</tt> </li><li><tt>index.php</tt> </li></ol> <a name="Creating_Your_Own_Page_Templates" id="Creating_Your_Own_Page_Templates"></a><h3> <span class="mw-headline">Creating Your Own Page Templates</span></h3> <p>The files defining each Page Template are found in your <a href="/web/20110623173221/http://codex.wordpress.org/Using_Themes" title="Using Themes">Themes</a> directory. To create a new Custom Page Template for a Page you must create a file. Let's call our first Page Template for our Page <tt>snarfer.php</tt>. At the top of the <tt>snarfer.php</tt> file, put the following: </p> <pre><?php /* Template Name: Snarfer */ ?> </pre> <p>The above code defines this <tt>snarfer.php</tt> file as the "Snarfer" Template. Naturally, "Snarfer" may be replaced with most any text to change the name of the Page Template. This Template Name will appear in the Theme Editor as the link to edit this file. </p><p>The file may be named <i>almost</i> anything with a <tt>.php</tt> extension (see <a href="/web/20110623173221/http://codex.wordpress.org/Theme_Development#Template_Files_List" title="Theme Development">reserved Theme filenames</a> for filenames you should <i>not</i> use; these are special file names WordPress reserves for specific purposes). </p><p>What follows the above five lines of code is up to you. The rest of the code you write will control how Pages that use the Snarfer Page Template will display. See <a href="/web/20110623173221/http://codex.wordpress.org/Template_Tags" title="Template Tags">Template Tags</a> for a description of the various WordPress Template functions you can use for this purpose. You may find it more convenient to copy some other Template (perhaps <tt>page.php</tt> or <tt>index.php</tt>) to <tt>snarfer.php</tt> and then add the above five lines of code to the beginning of the file. That way, you will only have to <i>alter</i> the HTML and PHP code, instead of creating it all from scratch. Examples are shown <a href="#Examples" title="">below</a>. Once you have created the Page Template and placed it in your Theme's directory, it will be available as a choice when you create or edit a Page. (<b>Note</b>: when creating or editing a Page, the Page Template option does not appear unless there is at least one template defined in the above manner.) </p> <a name="Examples_of_Pages_and_Templates" id="Examples_of_Pages_and_Templates"></a><h2> <span class="mw-headline"> Examples of Pages and Templates </span></h2> <p><span id="Examples_of_Pages"></span><span id="Examples"></span> </p><p>The following is a list of instructional examples. Feel free to make additions. </p> <a name="Archives_with_Content" id="Archives_with_Content"></a><h3> <span class="mw-headline">Archives with Content</span></h3> <p>A Page Template that shows the Page's content at the top, and then displays a list of archive months and categories below it. This is designed to work with WordPress's Default theme (aka Kubrick), but will probably work with many other themes with a little modification. </p><p>Save this to <tt>arc-cont.php</tt>: </p> <pre> <?php /* Template Name: Archives with Content */ ?> <?php get_header(); ?> <div id="content" class="widecolumn"> <?php if (have_posts()) : while (have_posts()) : the_post();?> <div class="post"> <h2 id="post-<?php the_ID(); ?>"><?php the_title();?></h2> <div class="entrytext"> <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?> </div> </div> <?php endwhile; endif; ?> <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?> </div> <div id="main"> <?php include (TEMPLATEPATH . '/searchform.php'); ?> <h2>Archives by Month:</h2> <ul> <?php wp_get_archives('type=monthly'); ?> </ul> <h2>Archives by Subject:</h2> <ul> <?php wp_list_categories(); ?> </ul> </div> <?php get_footer(); ?> </pre> <a name="A_Page_of_Posts" id="A_Page_of_Posts"></a><h3> <span class="mw-headline">A Page of Posts</span></h3> <p>A Page Template that displays posts from a specific category depending on a <a href="/web/20110623173221/http://codex.wordpress.org/Custom_Fields" title="Custom Fields">Custom Field</a> assigned to a Page. In this example the value of the Custom Field "category" is retrieved and used as the category to retrieve the posts in that category. So if the category of posts you want to display is called "Events" then assign the Custom Field "category" with a value of "Events" to the Page. Note that this will adhere to pagination rules meaning that four (4) posts will display per page with links to older/newer posts provided. This is designed to work with the WordPress Default theme (aka Kubrick), but should work with other themes with a little modification. </p><p>Save this to <tt>pageofposts.php</tt> and then assign PageofPosts as the Template when creating the action Page: </p> <pre> <?php /* Template Name: PageOfPosts */ get_header(); ?> <div id="content" class="narrowcolumn"> <?php if (is_page() ) { $category = get_post_meta($posts[0]->ID, 'category', true); } if ($category) { $cat = get_cat_ID($category); $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $post_per_page = 4; // -1 shows all posts $do_not_show_stickies = 1; // 0 to show stickies $args=array( 'category__in' => array($cat), 'orderby' => 'date', 'order' => 'DESC', 'paged' => $paged, 'posts_per_page' => $post_per_page, 'caller_get_posts' => $do_not_show_stickies ); $temp = $wp_query; // assign orginal query to temp variable for later use $wp_query = null; $wp_query = new WP_Query($args); if( have_posts() ) : while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small> <div class="entry"> <?php the_content('Read the rest of this entry »'); ?> </div> <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p> </div> <?php endwhile; ?> <div class="navigation"> <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div> <div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div> </div> <?php else : ?> <h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <?php get_search_form(); ?> <?php endif; $wp_query = $temp; //reset back to original query } // if ($category) ?> </div> <?php get_sidebar(); ?> <?php get_footer(); ?> </pre> <a name="A_Page_of_Posts_for_a_Custom_Post_Type" id="A_Page_of_Posts_for_a_Custom_Post_Type"></a><h3> <span class="mw-headline">A Page of Posts for a Custom Post Type</span></h3> <p>A Page displaying the posts belonging to a custom post type. In this case, the custom post type is <b>book</b>. The Template below is designed to work with the <a href="/web/20110623173221/http://codex.wordpress.org/Glossary#Twenty_Ten_theme" title="Glossary">WordPress TwentyTen theme</a> but is best used as a <a href="/web/20110623173221/http://codex.wordpress.org/Child_Themes" title="Child Themes">Twenty Ten Child Theme</a>. </p> <pre> <?php /** * Template Name: Page of Books * * Selectable from a dropdown menu on the edit page screen. */ ?> <?php get_header(); ?> <div id="container"> <div id="content"> <?php $type = 'book'; $args=array( 'post_type' => $type, 'post_status' => 'publish', 'paged' => $paged, 'posts_per_page' => 2, 'caller_get_posts'=> 1 ); $temp = $wp_query; // assign orginal query to temp variable for later use $wp_query = null; $wp_query = new WP_Query($args); ?> <?php get_template_part( 'loop', 'index' );?> </div><!-- #content --> </div><!-- #container --> <?php get_sidebar(); ?> <?php get_footer(); ?> </pre> <a name="WordPress_as_a_CMS" id="WordPress_as_a_CMS"></a><h2> <span class="mw-headline"> WordPress as a CMS </span></h2> <p>You can use WordPress for basic content management. If you do, you'll probably create a large number of pages for your content. </p> <a name="Using_a_Page_as_the_Front_Page" id="Using_a_Page_as_the_Front_Page"></a><h3> <span class="mw-headline"> Using a Page as the Front Page </span></h3> <p>A Page can easily be set to be your site's Front Page. Visit the <a href="/web/20110623173221/http://codex.wordpress.org/Administration_Panels" title="Administration Panels" class="mw-redirect">Administration</a> > <a href="/web/20110623173221/http://codex.wordpress.org/Administration_Panels#Reading" title="Administration Panels" class="mw-redirect">Settings</a> > <a href="/web/20110623173221/http://codex.wordpress.org/Settings_Reading_SubPanel" title="Settings Reading SubPanel" class="mw-redirect">Reading</a> panel and under <b>Front page displays</b>, you can choose to set any (published) Page or Posts Page as the Front Page. The default setting shows your blog with the latest blog posts. </p> <a name="Templates_by_page-ID_or_page-Slug" id="Templates_by_page-ID_or_page-Slug"></a><h2> <span class="mw-headline"> Templates by page-ID or page-Slug </span></h2> <p>You can use different archives "page", with ID or slug in your name. <strong>Only Available</strong> with <strong>Version 2.9</strong>. </p><p>examples: </p> <ul><li> page-{id}.php </li><li> page-{slug}.php </li></ul> <a name="Including_a_Page" id="Including_a_Page"></a><h2> <span class="mw-headline"> Including a Page </span></h2> <p>You might also want to include Pages in various places on your site. That way, you can have an easy way to edit elements of your website. There is a Plugin called <a href="https://web.archive.org/web/20110623173221/http://wordpress.org/extend/plugins/improved-include-page/" class="external text" title="http://wordpress.org/extend/plugins/improved-include-page/">Improved Include Page</a> that makes doing this easy. </p> <a name="The_Dynamic_Nature_of_WordPress_.22Pages.22" id="The_Dynamic_Nature_of_WordPress_.22Pages.22"></a><h2> <span class="mw-headline"> The Dynamic Nature of WordPress "Pages" </span></h2> <p>A web page can be <i>static</i> or <i>dynamic.</i> Static pages, such as a regular HTML page that you might create with Dreamweaver, are those which have been created once and do not have to be regenerated every time a person visits it. In contrast, dynamic pages, such as those you create with WordPress, do need to be regenerated every time they are viewed; code for what to generate has been specified by the author, but not the actual page itself. These use extensive PHP code which is evaluated each time the page is visited, and the content is thus generated on the fly, upon each new visit. </p><p>Almost everything in WordPress is generated dynamically, including <b>Pages</b>. Everything you and others write in WordPress (Posts, <b>Pages</b>, Comments, Blogrolls, Categories, etc.) is stored in your <a href="/web/20110623173221/http://codex.wordpress.org/Glossary#MySQL" title="Glossary">MySQL</a> database. When your site is accessed, that database information is then used by your WordPress <a href="/web/20110623173221/http://codex.wordpress.org/Theme_Development#Theme_Templates" title="Theme Development">Templates</a> from your current <a href="/web/20110623173221/http://codex.wordpress.org/Using_Themes" title="Using Themes">Theme</a> to generate the web page being requested. Thus, WordPress information is dynamic, including the information contained in your <b>Pages</b>. </p><p>An example of a static page might be an <a href="/web/20110623173221/http://codex.wordpress.org/Glossary#HTML" title="Glossary">HTML</a> document (without any <a href="/web/20110623173221/http://codex.wordpress.org/Glossary#PHP" title="Glossary">PHP</a> code) you've written as an addition to your dynamically generated WordPress pages, perhaps an "About Me" page. The problem with purely static pages is that they are difficult to maintain. Changes you make to your WordPress settings, <a href="/web/20110623173221/http://codex.wordpress.org/Using_Themes" title="Using Themes">Themes</a> and <a href="/web/20110623173221/http://codex.wordpress.org/Theme_Development#Theme_Templates" title="Theme Development">Templates</a> will not be propagated to pages coded only in HTML. The <b>Page</b> feature of WordPress was developed, in part, to alleviate this problem. By using <b>Pages</b>, users no longer have to update their static pages every time they change the style of their site. Instead, if written properly, their dynamic <b>Pages</b> will update themselves along with the rest of your blog. </p><p>Despite the dynamic nature of <b>Pages</b>, many people refer to them as being static. In the context of web publishing, static and dynamic mean what has been described above. More generally, however, static can mean "characterized by a lack of change". It is easy to see how this definition influenced the word's use in describing types of web pages. It is also easy to see why people think of <b>Pages</b> as being static; Posts come and go, but <b>Pages</b> are here to stay since <b>Pages</b> are typically used to display information about your site which is constant (e.g., information about yourself, description of your site). </p><p>In other words, a <b>Page</b> contains <i>static information</i> but is <i>generated dynamically</i>. Thus, either "static" or "dynamic" may be validly used to describe the nature of the WordPress <b>Page</b> feature. However, in order to avoid confusion, and because <b>Pages</b> <i>themselves</i> are dynamic while it is only their <i>contents</i> which are in some way static, this document does not refer to <b>Pages</b> as being static. </p> <!-- NewPP limit report Preprocessor node count: 92/1000000 Post-expand include size: 1156/2097152 bytes Template argument size: 482/2097152 bytes Expensive parser function count: 0/100 --> <div class="printfooter"> Retrieved from "<a href="https://web.archive.org/web/20110623173221/http://codex.wordpress.org/Pages">http://codex.wordpress.org/Pages</a>"</div> <div id="catlinks"><div id="catlinks" class="catlinks"><div id="mw-normal-catlinks"><a href="/web/20110623173221/http://codex.wordpress.org/Special:Categories" title="Special:Categories">Categories</a>: <span dir="ltr"><a href="/web/20110623173221/http://codex.wordpress.org/Category:Getting_Started" title="Category:Getting Started">Getting Started</a></span> | <span dir="ltr"><a href="/web/20110623173221/http://codex.wordpress.org/Category:Design_and_Layout" title="Category:Design and Layout">Design and Layout</a></span> | <span dir="ltr"><a href="/web/20110623173221/http://codex.wordpress.org/Category:Templates" title="Category:Templates">Templates</a></span></div></div></div> <!-- end content --> </div> <div class="col-2"> <ul class="submenu"> <li id="n-mainpage"><a href="/web/20110623173221/http://codex.wordpress.org/Main_Page">Home Page</a></li> <li><a href="/web/20110623173221/http://codex.wordpress.org/WordPress_Lessons">WordPress Lessons</a></li> <li><a href="/web/20110623173221/http://codex.wordpress.org/Getting_Started_with_WordPress">Getting Started</a></li> <li><a href="/web/20110623173221/http://codex.wordpress.org/Working_with_WordPress">Working with WordPress</a></li> <li><a href="/web/20110623173221/http://codex.wordpress.org/Blog_Design_and_Layout">Design and Layout</a></li> <li><a href="/web/20110623173221/http://codex.wordpress.org/Advanced_Topics">Advanced Topics</a></li> <li><a href="/web/20110623173221/http://codex.wordpress.org/Troubleshooting">Troubleshooting</a></li> <li><a href="/web/20110623173221/http://codex.wordpress.org/Developer_Documentation">Developer Docs</a></li> <li><a href="/web/20110623173221/http://codex.wordpress.org/About_WordPress">About WordPress</a></li> </ul> <h3>Codex Resources</h3> <ul class="submenu"> <li id="n-portal"><a href="/web/20110623173221/http://codex.wordpress.org/Codex:Community_Portal">Community portal</a></li> <li id="n-currentevents"><a href="/web/20110623173221/http://codex.wordpress.org/Current_events">Current events</a></li> <li id="n-recentchanges"><a href="/web/20110623173221/http://codex.wordpress.org/Special:RecentChanges">Recent changes</a></li> <li id="n-randompage"><a href="/web/20110623173221/http://codex.wordpress.org/Special:Random">Random page</a></li> <li id="n-help"><a href="/web/20110623173221/http://codex.wordpress.org/Help:Contents">Help</a></li> </ul> </div> </div> </div> <div id="footer"> <div class="wrapper"> <p> <a href="https://web.archive.org/web/20110623173221/http://wordpress.org/about/privacy/">Privacy</a> | <a href="https://web.archive.org/web/20110623173221/http://wordpress.org/about/gpl/">License / GPL</a> See also: <a href="https://web.archive.org/web/20110623173221/http://wordpress.com/" title="Hassle-free WP hosting">WordPress.com</a> | <a href="https://web.archive.org/web/20110623173221/http://wordpress.tv/" title="Videos, tutorials, WordCamps">WordPress.TV</a> | <a href="https://web.archive.org/web/20110623173221/http://central.wordcamp.org/" title="Find a WordPress event near your home">WordCamp</a> | <a href="https://web.archive.org/web/20110623173221/http://jobs.wordpress.net/" title="Find or post WordPress jobs">WP Jobs</a> | <a href="https://web.archive.org/web/20110623173221/http://ma.tt/" title="Co-founder of WordPress, an example of what WordPress can do">Matt</a> | <a href="https://web.archive.org/web/20110623173221/http://www.facebook.com/WordPress">Fan WP on Facebook</a> | <a href="https://web.archive.org/web/20110623173221/http://wordpress.org/news/feed/" class="rsslink">Blog RSS</a> </p> <h6>Code is Poetry</h6> </div> </div> </body> <!-- Cached 20110613131257 --> </html> <!-- user: NULL --> <!-- FILE ARCHIVED ON 17:32:21 Jun 23, 2011 AND RETRIEVED FROM THE INTERNET ARCHIVE ON 01:39:07 Nov 27, 2024. JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. SECTION 108(a)(3)). --> <!-- playback timings (ms): captures_list: 0.673 exclusion.robots: 0.034 exclusion.robots.policy: 0.021 esindex: 0.013 cdx.remote: 6.063 LoadShardBlock: 423.373 (3) PetaboxLoader3.datanode: 138.567 (4) PetaboxLoader3.resolve: 412.118 (2) load_resource: 130.659 -->