Related Pages Code Snippet for WordPress

I’m currently working on getting the documentation together for our API (with Fresh Vine) and I needed a bit of code to place in the sidebar that would display any resources from the same family.

Within WordPress I have the pages all nicely nested. So there is a top-level page with a slug ‘api’ (page ID 16), and that has a child slugged ‘documentation’ (page ID 20). This related pages script will check for the children of ‘documentation’ including the first level which we add in at the beginning there.

The page hierarchy looks like: api-> documentation->members->view-id (for example)

The Code

php $Page = get_post();		// Get the Current Page
$ParentID = $Page->post_parent;	// Get the Parent Page ID
if( $ParentID == 16 )
	$ParentID = NULL;	// We're a child of
else if( $ParentID == 20 )
	$ParentID = $Page->ID;	// We 

$Related = get_pages( array(
					    'child_of' => $ParentID,
					    'sort_order' => 'ASC',
					    'sort_column' => 'post_title',
					    'hierarchical' => 0,
						'parent' => -1,
						'post_type' => 'page',
						'post_status' => 'publish' ) );
// Look to see if there are any related pages.
if( !is_null( $ParentID ) ){

	// Get the Parent Page
	$Parent = get_page( $ParentID );	?>
	 post_title; ?>>

post_content ) // Check for empty page
				continue;	?>
		 post_title; ?>

Final Thoughts

All in all the code works splendidly. Though I have taken out all of my styling for this example I have it setup to display the method and to give visual indicators of what page the user is currently on (with a simple if $rPage->ID == $Page-ID check).

Well I hope this was helpful for someone else out there in the inter-webs. If you used the code leave a note so I can see how you used it!

Optimizing our App while moving

It has been a bit of a crazy last two weeks. Aside from moving into a new unit (now on the top floor with a great view, and almost no noise!), I’ve been working my butt off on stuff for nineteen05. It’s so excited to see how far everything has come in the past year. It is almost unbelievable.

I was trying to remember back when I was first integrating the podcast  features and it seems so long ago that I just assume that it was and has always been there. Finally to the last two major pieces of development, as it was laid out in January 2008. The thought of having all the initial development completed is astounding to me.

We can hardly wait to drop this who app on the church community as a whole. The first major introduction is coming in march with Substance Church. I’d say more but I figure making you wait is just as much fun.

Well I must be going. Have to finish putting everything away before my wife gets back from spending time with a friend. Will try to post a new photo of our view soon.

Books I read in 2008

I hope this list ends up being comprehensive but I’m really just looking at my book shelf and trying to remember what I read, if for work or pleasure. Of this list I know there are some books i read in full for different courses in the past year that aren’t here because they were from a library somewhere.  So as best as i could and in no particular order, aside from how they sit on my bookshelves, here it is! Continue reading