wordpress

branching out

Saturday, July 3rd, 2010

on thursday, i turned 31.

to celebrate, i wandered around san francisco with my friend ambur.

we visited several independent bookstores, got a taco, commissioned a $7 reflection on pickles and the number 31 from a man sitting on the corner of haight & ashbury with a typewriter and a sign reading: ‘pick a topic. pick a price. get a poem.”, met up with rongo! for dinner in chinatown, and saw the last airbender in 3D.

i also thought a lot about my goals for the year, and launched a new blog.

i have been thinking about splitting this blog into several more focused pieces for a while now, but i keep getting distracted, and in the meantime, my real goal is to just start writing more, anywhere, about anything, and for whatever reason i am having a hard time writing regularly here because i have this preconception about the sorts of things i want to write about, and it hangs me up.

so for my birthday, i decided to try starting fresh and clean, with the simple goal of writing something every single day for a year, just to see what happens. after a bit of brainstorming with ambur, i chose the name revolution 31, because that’s how many times i have traveled around the sun now, and also because the project is a vehicle for change.

i am using wordpress.com, instead of hosting the blog myself, because i want it to be as easy as possible, and i keep recommending wordpress.com to friends, so it will be good to keep my inside knowledge up to date.

i figure i’ll still blog here sometimes, or at least cross-post some things, but if you’re interested in following the whole year, point your feed readers to http://revolution31.wordpress.com/feed/.

now back to celebrating that other revolution.

cue fireworks.

wordpress hackery for the day – automatically generate category rss links for category archive pages

Thursday, January 29th, 2009

i’m helping my dad set up a blog for his law office, and he’s decided to focus on a few main category areas and build up audiences for each.

i told him that we could use the category archives that wordpress generates to filter the posts. then we could link to these pages and style them however we want as we design the site as a whole, and people can subscribe to the rss feeds for only the categories they want.

i was not lying, but today when i actually set about to ask the category feeds to play nice with my dad’s theme, it was a little bit harder than it should have been, and i decided to blog about my solution.

the theme has a big friendly “subcribe to our feed!” link, that i like very much, and it uses a file that it calls ‘subscribe.php’ to generate the link, which i also like. for those of you playing along at home, that means that you can just include ‘subscribe.php’ anywhere you want an rss link to show up, and if you ever want to change the way the link works, you only have to update one file. hurray!

for my purposes, however, a different rss link needs to be generated when you are on a category page, and it has to be the right one. one way of doing this would be to make a custom category template for each page, which wordpress lets you do by making pages like ‘category-17.php’ in your theme folder. but that would be annoying, and it would take away the benefit of having only one piece of code to change, which would be even more annoying, not to mention bad practice.

the better way is to add a condition to the ‘subscribe.php’ file that checks to see if the page you are on is a category archive, and then generates the appropriate rss link. that should be easy enough, but i couldn’t find a function that automatically retrieves category-specific rss feeds, and the otherwise convenient fact that there are several different ways to refer to rss feeds (but only one way to refer to a category-specific feed), was giving me trouble.

sigh.

i spent a while searching the wordpress codex to see if someone had already written the code or a plugin for me, because it seems like the kind of thing that would be a relatively common desire. sure enough, i found lots of people who wanted to do this, but only one who seemed to have succeeded, and his solution seemed really wonky to me and i wasn’t sure it would even work in the new version of wordpress.

in many ways, the strength of the wordpress community spoils me for times like this. i can almost always find answers to my codex questions in less than five minutes, so when i can’t, i just assume the answer isn’t out there, which probably isn’t true. in any case, if i can’t find the answer before i get tired of looking, other people probably can’t either, so it seemed like a good opportunity to increase the number of answers in the pool. :)

after a few frustrations with brackets and such that are par for the course, i made it work!

‘subscribe.php’ now uses the following code to generate the RSS link:

" title="Subscribe to this Feed via RSS">Subscribe via RSS

that’s a lot of babbling so i won’t say more unless there are questions.
good night and good luck!