On More Coding Thoughts

Yes, I’ve been away. Crushing deadlines will that to a person.

Tomorrow, I promise my long-awaited blog post on Star Trek: The Next Generation/Doctor Who: Assimilation2 #4. It’s something I’ve been wrestling with for about two weeks now.

At the moment, though, I’m going to write about where things are with my website redesign.

1) Mobile

I thought about trying to figure out how to make the theme I’m using responsive to display width. I spent some time studying CSS code for some other WordPress themes, looking at how others made the 960 Grid responsive, that sort of thing.

I decided, instead, to make things easy.

I was pointed in the direction of a WordPress plugin, Device Theme Switcher. This plugin enables a site to serve a different theme if someone arrives on a mobile phone or a tablet, and you can specify themes for both eventualities.

For the mobile phone, I’m going to use Minileven as the theme. For tablets, I will probably use Twenty Twelve once that’s released for self-hosted WordPress.

Both I’ll modify somewhat with child themes to factor in some of the customizations I’m putting into my main theme.

2) Custom Taxonomy

I need to create a custom taxonomy for a specific type of post. I could manage this classification through either Categories or Tags, but that has disadvantages and would muddle things up elsewhere in the site. I could also use Custom Fields on the fly, but that wouldn’t be as easy or convenient in regular use. A custom taxonomy would give me an extra meta box with a checkbox on the post composition screen to mark these posts as they’re made. It’s more code on the back-end, but the end result is convenience. The base theme I’m building off of uses a custom taxonomy, so I should be able to modify that code to my ends then modify the loop that I currently have to pull posts from that taxonomy.

3) Custom Menu/Walker

Something I’ve hard-coded into the front page I think would be better handled as a custom menu. This would give me the flexibility to change the three links provided as I see fit through the WordPress menu management system rather than editing my code directly. To accomplish this, I’ll need to write a custom walker to pull post thumbnails for this “menu.” I have some example code, so this shouldn’t be more than an evening’s worth of work to code and test.

4) Sticky Post

I’m not sure that I need and/or want this. The base theme I’m working with implements the sticky post in an interesting way, but because I’ve created a custom homepage marking something as a sticky post has no effect. I’m not sure if it’s something I need to implement (in other words, find a place for) or if I can function without it. To be honest, I’m not sure that I need it. However, it might be better to implement it, but put a conditional on it so that if there isn’t a sticky post then that section of the homepage drops away. This will require some thought, because I’ll also have to decide where it will go.

5) Drabbles

How to handle these, that’s the question. They’re in a separate database in my current WordPress installation, handled by a long-out-of-date plugin called Miniblog. I’d much rather move these into the standard WordPress database tables, but then it becomes a question of how to display them — and not display them.

It’s going to require this code (from this website), I think…

add_action('pre_get_posts', 'exclude_categories_' );

function exclude_categories_($toExclude) {
  global $wp_query; // Use this variable to assign the categories to exclude
  $categoriesExclude = '-3 -10 -11'; //this is just an example. Change the ids to fit your needs
  // this example will exclude the categories assigned to the $categoriesExclude variable
  //from homepage, archives pages, feeds but not from categories pages
  if( is_home() || is_feed() ||( is_archive() && !is_category() )) {
    $wp_query->query_vars['cat'] = $categoriesExclude;
  }
}

With modifications, of course. That will get me started (and it will keep me from having to recode other loops), but I’ll also need to create a page template to handle their display in the way that I want them displayed.

I’m sure there’s something I’m forgetting, but those are the five big areas that are preoccupying me with the WordPress coding at the moment.

Published by Allyn

A writer, editor, journalist, sometimes coder, occasional historian, and all-around scholar, Allyn Gibson is the writer for Diamond Comic Distributors' monthly PREVIEWS catalog, used by comic book shops and throughout the comics industry, and the editor for its monthly order forms. In his over ten years in the industry, Allyn has interviewed comics creators and pop culture celebrities, covered conventions, analyzed industry revenue trends, and written copy for comics, toys, and other pop culture merchandise. Allyn is also known for his short fiction (including the Star Trek story "Make-Believe,"the Doctor Who short story "The Spindle of Necessity," and the ReDeus story "The Ginger Kid"). Allyn has been blogging regularly with WordPress since 2004.

Leave a Reply

Your email address will not be published. Required fields are marked *