If you’re going to be creating an alphabetical index of regular old blog posts, then you can skip that first step.Īnd, in case you’re wondering, yes, you could do all three of these things in your theme’s functions.php. Use the ‘save_post’ hook to automagically assign new posts to the right taxonomy.Register a custom post type (I’m working with songs and song titles for my example).This new plugin is going to do three things: And here’s how you can accomplish this bit of WP magic: 1. But with this little push in the right direction, I was off and running. I was lucky to come across this post from Kathy is Awesome which set me on a much, much better path, though I quickly realized this bit of code was missing a few important things I needed. As I started hunting for and finding the bits of code scattered throughout the theme and plugins I’d written to accomplish that last time, I realized that there had to be a better way to go about this. I’ll just open up that project from last year, and copy … OH SWEET MOTHER OF CHEESE WHAT WAS I THINKING?” Yeah. …and my first thought was, “Oh hey, I know how to do that. And then I promptly forgot about that ball of kludgy code…until that same designer handed me a design comp for another WordPress project just a couple months ago: I remember spending quite a bit of time hacking that all together and being pretty pleased with the results at the time. It involved writing quite a few custom functions – one to generate that bunch of links you see in that image above, one to register a query parameter so I could use it in WordPress, and then a few more functions to do the right queries in the database, a bunch of code in the template to make sure I was showing the right posts…and on and on. I managed to cobble together a solution that works pretty well. ![]() …where clicking on one of those letters would take you to a page showing only posts with titles starting with that letter. About a year ago, I was handed a design comp from a designer that required me to build out an alphabetical index for a custom post type in WordPress.
0 Comments
Leave a Reply. |