Built a custom WordPress theme

I teach wordpress at work, and last quarter I had a student who wanted a really fancy wordpress site. She didn’t like any of the free themes. I told her I’d been tinkering with a custom theme for a couple years, but had never tried to use it on real, meaningful content. I simply had too many questions about how a custom theme worked in real life.

She was willing to put in the time, and I was being paid to teach…so we chipped away at it in the afternoons for a few weeks. Her website ended up looking so good I decided to try my hand coded custom theme on my 9 year old wordpress site. You are looking at it now. It’s a reasonably close match to my main www.websterart.com website, which is all handbuilt, not using wordpress. I’ve yet to try getting the PhotoSwipe plugin to work. Well, I did get it to work with my theme, but it caused problems.

WordPress, by default, puts thumbnails in definition lists. But PhotoSwipe requires them to be in figure elements. And I’d like to style the figure elements in variable column-count columns. However, there is simply too much code going on with his switch from dl’s to figures, which happens in JavaScript. More on that later.

There is a lot going on here. As far as explaining it, I don’t even know where to start. I may write a tutorial on it later. If you’d like to get the zip file of the theme, it is here. Be forewarned though, a lot of what goes on is in the form of widgets, menus and plugins that get added after you activate the theme in the wordpress dashboard.

Programmed a working calendar for journal

On February 3 I posted the working example from a calendar lesson I had learned in JavaScript. All it did was generate months of the year with the correct number of days, depending on which month you selected. It was dumb but it got me thinking.

As I moved forward in my JavaScript studies I was mulling over a way to make use of that calendar. To the right of this story you will see two calendars. The top one is a free WordPress plugin. I didn’t build it, I just installed the plugin.  It lets you switch between journal entries going back to 2011 when I first started using WordPress. All the post entry links are automatically populated from the WordPress database.

But I was keeping an online journal long before they invented WordPress. I have been writing since late 1997,  a year after I got my first computer. There was a story that year in the Seattle times about a woman who was keeping an online journal. She started it in ’97, and it inspired me to do the same. But as my journal grew it was difficult to build a navigation system back through the entries. I’ve struggled with a number of solutions, as you will see if you prowl around.

The one I used the longest was a flash calendar that I built from scratch. But even I refuse to download flash anymore. So if I was on a smartphone,  I couldn’t navigate my own journal until just recently.

My solution? Build a real working calendar in Javascript and embed it on every page , or at least the pages starting at September 2001, which is when I changed the interface drastically. To get it to work I had to create a JavaScript array for every year, about 10 of them.

As you can see to the right, I also embedded that new JavaScript calendar right here in WordPress below the plug in calendar. I got it to appear by using a WordPress plugin called shortcoder. The shortcoder plugin presents itself as a box in which you can paste html, css and js. Then it gives you a short little snippet of code, called a shortcode. That shortcode references the longer code. I pasted the shortcode snippet into a standard text widget, and dropped the widget into my WordPress sidebar.

You can see it all working here. It’s not search engine friendly yet…I have to think about that. I’ve linked to the contents (hand built index of the journal) page. It has links out to most of the good writing, perhaps that will negate the fact that a dynamically generated calendar can’t be spidered by google.

I’m fairly happy with this solution. It’s not perfect, I think Jessamyn does a better job of archiving, but at least mine was a fun way to practice my JavaScript.

Here is the array for the year 2000. Note that I didn’t start writing until March of 1999, or, at least that is the first named file: three99.html

Next I modified the simpler calendar function from a week ago so that it dynamically generated the months for the selected year, complete with clickable links for each month. But there was a problem. If you selected say, April of 2004, when you got there, the calendar did not display. You had to choose a year again. This was bad usability. I wanted the calendar to always display all the months of the year you were reading, no matter which month you were reading. But that meant getting the pages to talk to each other. The technical term is: passing data between html pages. I had a vague idea that it might be doable with cookies, but I’ve never baked cookies.

Google to the rescue! I discovered there is a way to store and pass variables between pages that have JavaScript. It’s called localStorage. You can write to it, and pull data from it. As long as they are on a long session on your website, you can make your html pages pass data from page to page.

The first line below listens for you to make a choice from the drop list. If you do ‘change’ it, the script fires off the ‘createYear‘ function.

That function puts the year you chose into a variable called ‘choice‘. At the same time, it places that year into session memory via the localStorage.setItem command. This is like registering at a hotel and telling the concierge that you would like the Seattle Times news paper each time you walk in. He remembers your preference during your session at the hotel…all week long.

As you surf from month to month, the concierge (localStorage data) remembers your year preference and keeps that year’s calendar visible

Next I do a couple checks to see whether this is your second journal month choice, or if you just arrived and haven’t made any previous choices. If the latter, I present the first years calendar, which is 1999.

Further down I have a switch-case conditional that fires off the correct createMonths function for the year you selected.

In other news, Sue and I skied at Paradise yesterday. This was only her second trip of the year. She is still babying her rotator cuff surgery. It was a nice one inch covering of powder over a hard base. It wasn’t  grabby, and was lovely skiing, not counting the water runnels, which were as bad as moguls in spots. I went back up for another run, but the fog had settled in, masking the earlier bright blue sky. I turned around before Pan, and finished out the day.

Today I bought a $15 bouquet but discovered I’ve forgotten how to draw. Jeez! I’ve been so lost in programming I’ve not only forgotten how to climb, I can’t draw either. How come I can’t be good at everything? It would be so handy. Perhaps when I get a full time job again and get settled in I can get back to my hobbies. I miss them.

To keep from going crazy with all this studying I’ve been exercising every day and playing a fair amount of ping pong. Last week I played at the local community center with a bunch of seniors. We played doubles, which involves a very intricate dance around the end of the table. You have to hit the ball, but only every other time. This means you hit the ball, then run backwards to get out of the way so your partner can hit it…and repeat. It was so much fun I went to another public game out on 76th.

This was a beast of a different color. They were people of all ages, and they were serious, with a capital S! They literally wiped the floor with me. I lost.every.single.game. That’s nine games in a row, but who is counting? I walked out after an hour. I mean, what was the point? I love the game, but I don’t have the time to develop that kind of skill. I am already neglecting too many hobbies, don’t need to add ping pong to the list. I won’t stop playing, but I will avoid playing with people who live and breath the game.

When one door closes, another one opens

We’ve been making changes again to our program. The web program in which I teach has been around since last century. It’s always been a child of a larger program. First it was a certificate in the Media Program, which ran for over 20 years. When Media closed 5 years ago, we moved our web certificate over to the CPW program. That kept it alive, but it wasn’t an ideal fit. The CPW program focuses more on pure programming, as in building computer applications that manage a bowling competition, or allows students to view  college classes for the current quarter, complete with searchable query strings by teacher, program, etc.

CPW focuses on programming logic like Python, Java, .NET, C+, with a little bit of HTML and CSS thrown in, but no Photoshop at all. We have had great luck putting our smart students to work in places like insurance agencies, and the State of Washington  maintaining websites and databases.

But our long running web program was  the wild child in the CPW program. We cater  towards programmers who also see the artistic side of web development…as in, web design. We still feel that Photoshop and Illustrator are important skills for a free lance web developer to master. Of course, we also try to graduate full stack developers who can a build a responsive website with a hand built shopping cart written in JavaScript, PHP and MySQL. It is quite a good skill set we’ve been developing over the last 19 years, with a number of different teachers contributing various classes, including myself. As with CPW, we’ve had great success putting our smart students into full time jobs.

But because we include artistic concepts in our classes, it wasn’t a good fit with CPW. Not to say anything bad about them. They simply feel that they can hire out the artistic stuff…and that the programming is more important. We feel that both are important, programming, and design.

To make a long story short, our dean advised us to get a divorce. We are going to move our web program out of CPW and become our own degree. We’ve been teaching out the last students in the old web program, and not allowing new students in, to keep the transition period cleaner. What this means for me is that until our new web program starts up…and we’re not sure exactly when that will be, I am unemployed.

As the title of this post reads: When one door closes, another one opens. I’m super excited to have next quarter off. I plan to apply for unemployment, then start hitting the books, preparing myself for both the new program we hope to teach, and/or for working full time again as a web developer. I’m not sure which will happen first. If I do get a full time job, I’m sure our program will survive without me. Everyone is replaceable. And if I don’t find a full time job, by studying hard for an entire quarter, I will be able to get up to speed with some of the stuff I’ve fallen behind on, like frameworks and version control. I’ve done and used both, but not consistently, and not the latest versions.

So, to wrap up, next quarter is going to be very interesting. It will be odd to be on unemployment. I’ve only been truly unemployed once, and that was just for 3 weeks last century back when I was a printer. I was under-employed a few years ago for one quarter…but this time I will be truly out of work, and hitting the books everyday to make myself more employable. I’m going to have to be rigorous about turning down invitations to go skiing or climbing. I’ve got a lot of friends and family with great jobs who have a ton of time off. They’ve gotten used to inviting me on adventure trips mid week. I love those…but now I need to keep my nose to the grindstone. It will be fun learning new stuff.

Adding a logo in a WordPress custom theme

Add a logo image function to your custom theme

Geek alert! This post is for the students in my WordPress class. There is nothing here worth reading if you are looking for stories about climbing or painting. Read More