If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

If WordPress were a guy he would be The Man - Plugins I am not a coder. But I am a do it yourselfer. And with all my blogs, I either find out how to write code to accomplish a specific task, or I find a plugin. And this post is a bit of both.

First, take a look at my post regarding the addition of aerial golf course maps on my Columbus, Ohio centric blog the270.

At the end of my narrative, you will find a list of golf courses added to the blog. The list is automatic. That is, as I continue to add aerial golf course maps, WordPress automatically includes those maps to the list. I don’t have to go back and manually code the list.

First Create a Parent Page

Write Page

The first step in how I accomplished this was to create a page called “Golf”. To do, go to the Write Page tab and create a page with the Page Title “Golf”.

Next create Child pages

Parent Page

After I created the Golf page, which appears asĀ  http://the270.com/golf/, I created individual pages with the Golf course as the name of the page. In the right hand sidebar, goto the Page Parent field and select “Golf” as the parent page. Of course, your parent page will differ according to the name of your page.

The PHP code needed to display the “child” pages in alphabetical order

Next I did inserted the following PHP code in the text “code” field of my post.

<ul>
<?php wp_list_pages(’child_of=63&sort_column=post_title&title_li=&depth=1′) ?>
</ul>
The number “63″ of the above code corresponds to the ID code of the “Golf” page that I created. To determine the ID number of your page, goto the Manage > Pages tabs and search for your page title. The ID number will be to the left.

ID
In the example above, the “Golf Club of Dublin” post is a child of the “Golf” post. Hypothetically, I could have created another page with the “Golf Club of Dublin” being the parent. In this hypothetical, that post would be I guess the grandchild of the “Golf” post. I would not want to display the grandchild pages in my list. So to exclude grandchildren, you set the depth as 1 in the PHP code above.

But we are not yet finished.

Plugin to run PHP code within WordPress pages or posts

runPHPIf I stopped with the above and published the post, the list would not have generated. That’s because WordPress ignores PHP code within posts or pages. That’s where the plugin runPHP comes in handy. After you activate this plugin, you can insert PHP code within your posts or pages, and they will work.

In the right sidebar, all you need to do is make sure there is a check mark in the box next to the words “run PHP code?”

After that, just publish and let WordPress and PHP run its magic.

You Should Also Check Out This Post:

More Active Posts: