Categories
Development

Display WordPress Child Pages as a List of Links

After figuring this one out, it’s really easy to do but I did have a hard time since I didn’t bother to check and see if a specific function already existed to do this behavior.

I wanted to display all the child pages of a Page as an unordered list. I initially tried using the WP_Query function to make this work. I tried creating a loop and feeding it some parameters, but kept getting no results.

Upon some further searching I did come across the wp_list_pages() function. I’m not sure why I didn’t begin with this, but for some reason I was set on using WP_Query.

There’s a ton of parameters and some great examples found on the wp_list_pages() page.

Here’s the little bit of code I added to a template to output the child pages as a list. Notice that the parent page’s id is the 32 that you will see as a parameter below. Enter whatever your parent page’s id is in it’s place.

wp_list_pages('sort_column=menu_order&title_li=&child_of=32');

Doesn’t really get much easier that that.

Categories
Development

WordPress Template Errors with Dreamweaver CS4

This one had me scratching my head for a bit, so I figured I’d write it down.  While creating a new WordPress template the template name was coming up incorrectly in the WordPress admin. Instead of just displaying the name of the template, it was rendering all the info in the template. 

I kept checking existing templates that weren’t having this problem and could see no noticeable difference between mine and what they had typed. After much confusion, I decided that perhaps it was how Dreamweaver CS4 handled line returns. So I fired up a basic text editor and typed it all up and uploaded it and it worked fine! 

So now I’ll be coding up my WordPress templates in BBEdit not Dreamweaver CS4.