Sillybean
Easier internal links for WordPress
Last week I got into a conversation with my friend Fletcher about linking to internal pages in WordPress. To wit, it could be a lot easier. Wiki-style links would be better than nothing, but personally I hate having to remember special codes for things. Still, WordPress’s shortcode API does make this relatively easy to accomplish, and sure enough, someone had already done more or less what I wanted. His shortcodes look like this:
[link pagename="My Example Page"]
That wasn’t quite right, though. I wanted to use slugs instead of proper names, and include IDs, and be able to link to things other than posts and pages. So I’ve taken it a little further:
(Later this week I’ll probably add custom taxonomy support, now that I’ve sussed out how that works.)
So, mission accomplished… sort of. Fletcher would like something shorter, but we’re constrained by the API. We can’t have [link 2130], which would have been my first choice.
How could this be better? I’m thinking of adding a button to the visual editor toolbar that would pop up and prompt you for the ID or slug. If I can figure out how to put an auto-suggesting search box in that popup, I will. The HTML editor is trickier… I know I could put a button in for each of the various formats, but that’s a lot of buttons. I’m not sure if the quicktag popups support more than one input field. Suggestions welcome!
Creating a user directory, part 1: changing user contact fields
This is the beginning of a three-part series on building a user directory.
Part 1: Changing the contact fields on the user profile pages
Part 2: Building the user directory page template
Part 3: Building author templates and linking them in the directory
First, we’ll add some new fields: Twitter username, phone number, and job title. Then, we’ll remove the built-in fields we don’t want (all the IM handles). Finally, we add the filter that makes it all work. Here’s the code: (more…)
Add sortable, striped table script — only when needed
Ever wondered how I dressed up the tables on this site? I’ll show you! We’ll use the code for adding stylesheets and scripts conditionally to include Yoast’s improved sortable.js only when a post or page contains a table. (more…)
Bloomsbury caught whitewashing, AGAIN
Seriously, you’d think they could have learned a lesson from last time, but no.
So really, publishers, if you’re so convinced that a book with a dark-skinned heroine won’t sell unless readers are tricked into thinking she’s white, then just be honest about all of it — admit that you don’t want to risk publishing books about characters of color. Admit that white people are the only audience you really care about. Admit that you don’t give a tiny rat’s ass about that adolescent girl walking through a bookstore, trying to find a story about someone who looks like her and learning — probably for the umpteenth time that day — that only white people can be pretty or interesting.
UPDATE: They’re changing the jacket, even though the book was already in stores.
Create private categories
Have you ever tried to create a category consisting entirely of private posts? It’s a pain to have to remember to set the visibility for each post before publishing it. One of my users simply couldn’t remember to do it, resulting in a lot of accidentally public posts on that site.
To solve the problem, I created this little function that catches posts as they’re being saved. It checks to see if the post is in the right categories, and if it’s being published — that is, it leaves draft, pending, and scheduled statuses alone. (It’ll automatically catch the scheduled posts when they go live.) If the post is being published, it gets set to private. (more…)




