The concept of the page was simple: to build a directory of sorts for posts that were tagged with different locations on the island.
WordPress Repository Location: Posts by Tag
What Was Needed
I wanted to have a page that listed all the locations on Maui that my website featured, as well as each post associated with that location.
For the website, I’m was already using Categories for the primary navigation, such as Beaches, Activites, etc. But in order to track the location of each post, I was also tagging each post with a specific place name, such as Lahaina or Kapalua. After accumulating more than 40 posts from 11 different locations that were tagged, it was time to create a page that featured each location and list the posts assigned to it.
What Was Done
The Posts by Tag plugin actually works in two modes: a widget mode for use in a sidebar, and a shortcode mode that let you embed the list inside a post or a page. For this case, I was looking to the shortcode feature to help get the job done.
The post_by_tag shortcode functionality offered by Posts by Tag uses most of the same parameters as the get_posts template tag that WordPress offers, so right away I knew it had everything I needed. In my case, I wasn’t as concerned with the dates of the posts (as in a traditional blog sense) as much as having a directory listing of posts. So the fact that I could order the posts by Title and in Ascending order was perfect. The only other parameter required for me then was the number of posts to return, which I set at a generous 25.
With the shortcode usage planned, it was just a matter of laying out my page just like you would any other page. While the shortcode supported multiple tags at once, I was looking to add a photo and a link for each tag. At the time, there were 11 location tags that I wanted to display posts for, so I needed 11 instances of the shortcode on the page. I added all 11 locations and photos in the order I wanted, knowing that the next time I added a post and tagged it with one of these locations, it would be automatically added in correct list and in its proper order alphabetically.
Now, if I added a tag for a new location at some point, of course I’d have to go back and manually update the page, but that is a less frequent occurrence that I was not concerned with at time.
With the shortcodes utilized and the page in place, I was all set. A screenshot of the final result is below, but if you’d prefer to see the page itself, visit the Maui by Photo Locations page.
Please let me know if you think this short demo helped or if you’ve used this or a similar plugin on your own site, too.