If you create a Page, one for your Services, one for Information, then using the using the template tag, wp_list_pages(), in something like your theme’s sidebar.php will provide you with a link to any and all of your pages.
The WordPress Default 1.6 theme is an example of this.
Also note that if you use Widget then the Page widget would provide the links to your pages.
Finally, Pages have no Categorization.
Thread Starter
ansuk
(@ansuk)
Hi Michael and thanks for your reply. Im still confused though, i need it to be like this:
Services:
Ecommerce
Webdesign
Hosting
Recent Posts:
Post 1
Post 2
Post 3
Information: (different than Services)
Privacy
Terms
Contact
Does that make sense and is it possible?
Well you asked about Pages but your example mixes Pages and posts. Just to be clear, Pages don’t have Categories, but Pages do have Hierarchy. Pages don’t contain posts unless you use a Page Template that uses code such as query_posts() to display such posts.
For your example, you could use wp_list_pages to include the first Pages that are related to Services and it’s child Pages, then use the template tag, wp_get_archives() to display your recent posts, then use another instance of wp_list_pages to display links to the Information Page and its children Pages
So assuming Services is Page ID 5 and Information is Page ID 8, this code in the WordPress Default 1.6 theme’s sidebar.php seems to work:
<?php wp_list_pages('hierarchical=1&child_of=5&title_li=<h2>Services:</h2>' ); ?>
<li><h2>Recent Posts:</h2>
<ul>
<?php wp_get_archives('type=postbypost&limit=3'); ?>
</ul>
</li>
<?php wp_list_pages('hierarchical=1&child_of=8&title_li=<h2>Information:</h2>' ); ?>
Thread Starter
ansuk
(@ansuk)
Thanks for getting back to me Michael, its much appreciated. I think ive been looking at the whole thing wrongly and perhaps using Parent/Child pages is the way to go but the example above was meant to show how my left hand panel would look.
Thanks again.
Hi,
I’m trying to implement the above code submitted by MichaelH, but I can’t get it to work.
Like ansuk I want to list links to pages in the sidebar but have them show in different sections, the example ansuk gave was:
Services:
Ecommerce
Webdesign
Hosting
Information: (different than Services)
Privacy
Terms
Contact
I pasted the above code into sidebar.php (minus the code relating to ‘Recent Posts’) and created some pages – and this is where I suspect I might be going wrong as I’m unsure about how the page hierarchy works. When I add a new page does the ID correlate to the ordering i.e. Page 1 = ID 1 etc? Can somebody please help me to understand what the following code actually does, particularly the part in brackets?
<?php wp_list_pages(‘hierarchical=1&child_of=5&title_li=<h2>Services:</h2>’ ); ?>
Or do I need to use a page widget for this to work?
I’m using the default ‘kubrick’ theme with wordpress 2.7.
Thanks.