Wednesday, June 2, 2010

Revising Pugix's Wordpress Blog

Over the Memorial Day weekend I delved back into WordPress and made some needed changes for pugix.com, my husband's analog synthesizer blog. It uses WordPress 2.9.2, the current release, and a pack o' plugins.

In essence, we wanted to get current content onto the homepage, not just as a little "what's new" link in the sidebar. About four years ago I used WordPress to convert his static HTML, hard-to-maintain synth website into something that had better web presence and was more easily maintained and had an easier future development path. Now we wanted to make it a bit more blog-like by making the new content easy to find, and keeping the homepage fresh.



  1. Moved the site description to an "About" page.

    1. Hardest part was figuring out why an /about URL was pointing to the homepage. This blog had its genesis some years ago, and I knew I had done "something" to create a static page. As I recall, WordPress didn't have a handy static page user interface several versions ago. In the end I had to edit the homepage "post_name" field by directly modifying that record in the wp_posts table, since I couldn't find anyplace else that this was set. Happily, that worked.
    2. Created a new page called "About" but until I solved problem a. above I couldn't create a page with the url "/about" — I kept getting "about-2" forced on me. After that, adding an "About" link to the header.php theme was easy.
  2. Added the latest post to the homepage.

    1. Doing this needed a lot of research on The Loop. One of the many beautiful things about WordPress is its very rich documentation and community support. I've never really gone down a road that noone's gone down before, and once I research my question sufficiently to know the language to use, I can find the questions and answers to guide me.
    2. Below the homepage content, which consists of the halfling avatar portrait plus intro text, I had to add a second loop to pull in the most recent post. Since that required a special query limited to one post, I had to use the query_posts() function instead of the default query.
      query_posts('showposts=1');
      if (have_posts()) : while (have_posts()) : the_post();

  3. Set up the "older posts" navigation link from the homepage.

    1. This took most of a day for me to get it right because of the implications for the homepage template. I learned that next_post_link() does not work except in single-post view, and the homepage is a special kind of limit=1 list, not a single-post view because I am running two queries on that page. So, next_posts_link() is required, not "previous" as you might imagine: we are returning results of a date-descending sort, so even though the next post is temporally "previous" it is, in the list of results, "next", not "previous".
    2. Once I got the link working, I had a number of problems to resolve. I had to figure out why I wasn't actually seeing the next-most-recent posts on the page. I discovered that 14 posts were skipped before the post list merrily continued in correct date-descending order, because I was limiting the display to one post on the homepage. The site uses a 15-posts max-per-page pagination rule, so the 14 following posts were just disappeared, so I needed to re-query the posts and allow for an offset,
      if (!is_front_page()) {
      query_posts($query_string . '&offset=1');
      }

    3. UGH, I just realized this doesn't work; it refreshes the query on every pagination page, instead of carrying it through to subsequent pages. Back to the forums and documentation to figure this out!
    4. I could see a list of posts using the link, but the most-recent post was still showing below the list. The same template must be used to display the lists as you navigate through them, there was no way to say "after the homepage, when linking to the next/previous page, use a different template, mkay?" Nope, and logically that's correct. One is just navigating through a query result list, even if visually one thinks "now I'm on the homepage", then, "now I'm looking at a list of recent posts."
    5. So I realized I had to keep using the homepage template, and use conditionals in some way to hide and show content on following pages. I created a new template, home.php, and linked the homepage content to it using the publish page UI, very nice and simple. WordPress is a lot easier than Expression Engine 1.6x, although TBH, EE is much deeper with its multiple-blog-streams of organized content.
    6. sheesh, what kind of conditional can I use? I'm thinking along Expression Engine lines, where one parses segments of the URL to figure out where one is; it's clumsy IMO, but there is a nice plugin for EE that tells you if you're on a pagination page or a category view page, to help your conditional view management. But I soon stumbled on the very thing, is_front_page() and that was the last piece that I needed to control my template, though, truly, it's an ugly thing to read. I'm spoiled by the model-view-controller beauty of Zend Framework which allows one to isolate database query functions from the page layout mechanisms. Using MVC is a much nicer way to build and maintain any level of complexity. Of course that's more or less how WP extensions work; I'm just muddling around at the bottom-most rung of template-fuddling.
  4. Reduced the amount of text displaying in the music category list views, while still showing the podcast player.

    1. I discovered that the_excerpt was what I wanted to show, not the_content. Since he wasn't using the excerpt field in the publishing form, the first 55 words display by default. That was still too much, plus, I wanted to keep some of the HTML layout, especially the podcast player. So I researched the question and found a lovely plugin, Advanced Excerpt. This allowed me to to trim excerpts sitewide to 24 words, and manage which HTML tags displayed. I discovered that it doesn't correctly handle <a title="" href=""> formatted tags, although AFAIK they are syntactically correct, you have to put the href param first. No biggie.
  5. Made the navigation for category lists more prominent.

    1. Minor CSS tweaking here, and I had to add a div class to those template nav links. Just needed to be a larger font-size.

You'll notice that the module category list pages are special. I'm using Sobek's Posts in Categories plugin to create formatted lists that simply show titles and offer several sort order settings. These module posts are not like the sequential syndicate-oriented content, they are more a way to document in detail the modules of his analog synthesizer, so a nicely formatted list is more suitable than the usual query results, and it's easy to use. I created unique category templates for those lists, which one does quite easily in WordPress by adding a category-[IDnumber].php page for each category you want a unique template for.

1 comment:

  1. Sounds like some great improvements! I'm in the midst of a website redux myself, so I can relate.

    ReplyDelete