At first, most bloggers don’t consider the need for a static page. Maybe one that has some about details on, but nothing more. As time goes on they may add one or two more pages, then a couple more. If they’ve stuck with the same theme then they’re most likely manually coding in the page links into their site, or they come manually coded in the case of some of the free themes available. Good idea? Well not necessarily, not if you intend to maybe change the page slug, or add a new page, and forget that the process isn’t automated on the front end. One of the first free themes I used had manually coded page tabs and I couldn’t work out why my additional page wasn’t displaying until I realised this (I was a bit of a WordPress newbie at the time!).
Making your pages dynamic is pretty easy, understanding how flexible your page navigation can be will help too. Pages can be quite powerful parts of your WordPress site yet often get overlooked.
Before you can display page links on the front end you need to create a few pages. About, Contact Me/Us, Links, Portfolio, can all sometimes be found on a blog. The basics of creating a page are pretty similar to creating a post, however there are two additional options you can control within the add/edit page section.
The first is Page Template. You will only see this if you have one or more page templates in your theme (Kubrick comes with a links page template for example). I’ll explain how to create your own page templates another time, however some themes will come with them ready coded. Changing your page template from the default to a specific one will mean that additional code could be within the template, triggering the output of additional information. For example a links template usually lists all of your links specified in your blogroll without you needing to see the code that does this in the page content area.
The second is Page Order. You can control the order of your pages by assigning a number to each. Then in the list pages template tag you can specify to list the pages in your selected page order, ascending or descending.
The template tag used to dynamically list your pages on your site is wp_list_pages(). Used without parameters this displays a list item with the heading of Pages and an unordered list, the pages will be listed alphabetically. A few of the more used parameters are
You’ll possibly notice that most of these parameters are similar to those of wp_list_categories() as written about last week.
A simple example of using these parameters would be the following:
< ?php wp_list_pages('sort_column=menu_order&title_li=&depth=1&exclude=5,6') ?>
The above code would the output an unordered list, in menu order, only displaying the top level pages, and not displaying the pages with IDs of 5 and 6.
I’ve sometimes seen people say that they would manually code their page links in so that they could easily style them. However the output that WordPress produces provides a lot of scope for control and styling as you can see below:
<li class="pagenav">Pages
<ul>
<li class="page_item current_page_parent"><a href="/?page_id=1" title="page title">page parent</a>
<ul>
<li class="page_item current_page_item"><a href="/?page_id=2" title="page title">selected page</a></li>
</ul>
</li>
<li class="page_item"><a href="/?page_id=3" title="page title">another top level page</a></li>
</ul>
</li>
Every list item for a page has the class of ‘page_item’. Then the currently selected page also has a class of ‘current_page_item’. If the current page is a child of another page, the parent page will also have an additional class of ‘current_page_parent’.
There are plenty of plugins related to static pages. A couple that I find very useful are
Author comments are in a darker gray color for you to easily identify the posts author in the comments
Comments are closed since this post is older than 30 days. However, you can continue this discussion in our popular Blogging Forums
I really liked your entire blog. BTW, I have been here through Ben Spark SocialCardSter blogroll.
Thanks.,
Which version ? All of old versions ? humm. Try either WP2.5 or the latest 2.5.1, you’ll see page in search result.
Good one, thanks. There is so much flexibility in pages, there are certainly worth tinkering with for maximum potential.
With the ID #’s display being removed from the 2.5 admin a plugin I have found useful is , to help give an easier visual on the ID #’s for working on design and needing those for ‘include’, ‘exclude’ etc.
Nice post.
I just have one correction, plugin “Search Everything” is needed only for WordPress versions beyond 2.5
From WordPress version 2.5 default search searches everything, including static pages. So if your blog is based on WordPress v2.5 or newer, you really don’t need “Search Everything” plugin.
thank you so much for the info on the Excluded Pages plugin. I was not previously aware of it! But have been looking for something like it for quite some time! keep up the great writing!
Phoenix2Life – Sorry I don’t use blogger however there could be some older posts on the topic if you look through the posts on the site, or try the Blogging Tips forum.
Myo and Spale – I’d read rumours that the functionality of Search Everything was meant to be in the new version of WordPress, however didn’t see it mentioned on the new features list when it was released, and haven’t had a chance to check the search yet. It’s good to know it’s finally built in.
David – I use a similar plugin (Reveal IDs I think) which is essential from my point of view (I didn’t think to add that to the plugins list when I wrote the post!), cheers for mentioning it.
chase – it’s a very handy plugin, especially if you set up a multi page site (or what to set up a site for a non developer to use). Saves so much fiddling with the template files.
Just an additional comment on the Search Everything plugin, whilst it isn’t needed to allow WordPress to search pages anymore, it’s still useful to use to prevent WP from searching specific pages, posts or categories/tags. I’d have to do some tests to see how much searching WordPress actually does (comments, private pages, future posts etc.), whereas this gives some control easily over what is included in the search.
It’s not just about creating static Pages with a capital P in Wordpress but if you have legacy pages in conventional form you can call Wordpress to apply the template even to those with a couple of simple tweaks to the code.
db