Get Information About Top-Level Pages in WordPress

About a week ago, someone commented on my post about styling top-level pages differently in WordPress, asking how to get the slug for a top-level page while one of its descendant pages is being viewed.

It just so happened that I was in the process of working on a WordPress theme that needed to display the title of the top-level page on all of its descendants. As part of that process, I wrote a quick function that retrieves the top-level parent of any page on a WordPress site as a WordPress post object.

WordPress: Creating Custom Permalinks for Plug-Ins

Over the last week or so, I’ve been working to develop a new WordPress plug-in that sets up bi-monthly archives (to be generated for the first and fifteenth of the month by default). As part of that process, I needed to create custom permalinks to display these new archives. Unfortunately, the amount of information available on this matter is fairly limited. I had to gather information from a few different places and then use some of my own experience to finalize the process.

It’s entirely possible that there’s a better way to handle this situation, but this is what I was able to do.