As I was getting my template refined for the implementation of this site, I came across an interesting little code snippet.
What was I trying to do? I was working on adding what WordPress calls "Pages" to my site to use as static content for my project examples. Once I had added my pages, I needed to display these pages on my header.php. In order to do so, WordPress provides a function. Here's what the code looks like:
<?php wp_list_pages(); ?>
The issue with this function is it provides an entire list of links to each of your pages that you have added to WordPress. In my case, I had set up a number of Pages to be children [pages linked off] of the "Project Examples" page. It turns out that you can provide to the wp_list_pages() function an argument defining the depth of pages shown. If you wanted to only show one level of pages, you would use the value '1'.
I was able to choose the levels deep I wished to display pages from the parents. In doing this, the function would no longer display all my pages but rather just the top level. It's now up to me to manually link to the other existing pages in my content management system.
The final code:
<?php wp_list_pages('depth=1'); ?>
Note, you can also exclude individual pages from being displayed using this function. In order to do so, provide the id's of each page you would like to hide and format as such:
<?php wp_list_pages('exclude=12,43'); ?>
It turns out there is quite a bit you can do with this function. Check out the official WordPress docs for more
Welcome to Ryboe.com! This site has been started primarily as a platform for me to share my knowledge of the world of web development and share my adventures. The best way to get better at something is to teach others, so in large part this is an honor for me because I get to share my knowledge along with help others become better at what is ultimately a very exciting area of study — web development.
The reason why a blog is the perfect format for learning about the various technologies involved in developing with web languages has to do with evolution. The technologies involved in developing web sites and web applications are always evolving, and as a web developer you have to work hard to keep current. My focus with this blog is to bring to my audience the most up to date observances and tutorials on languages I am working with on a day to day basis. I may also decide to dive into various design aspects throughout. If you would like to get a quick overview of what Ryboe.com is all about, check out the about page on the site.
Thanks for coming! Oh, and don't forget to add this feed to your RSS reader using the buttons at the right of the site!



