Blogs just aren’t the same as they used to be. In the old days a blog was characterized by time and personality—chronology was important, and you read the blog because of the author, not the information he could give you.
Nowadays blogs are used more for short bursts of information about a single topic—typically a blogger’s expertise. The personality behind a site barely matters. “Content is king!” as you may recall.
So if chronology is no longer important, why post by date? I think part of the answer is that WordPress displays dates by default in most themes. Let me propose an alternative way of displaying content in WordPress. By tag frequency.
Making tags useful
Tags provide wonderful meta information about a post, but sadly this information is typically relegated to an ugly list in the sidebar. I say, if you’re going to go to the work of tagging all those posts, you had better use those tags for something useful!
By adding a couple snippets outside “The Loop” in WordPress you can display N number of posts by X tag. Here is an example to help make it a little more clear:
Imagine you have 20 posts tagged Home and Garden, 10 tagged Clearance, and 13 tagged Hardware. With a bit of PHP we can get WordPress to display posts from each tag in order of most popular to least popular. We can even take it a step further and limit the number of tags to display. The end result might look something like this:
HOME AND GARDEN * Tag 1 Post 1 Title * Tag 1 Post 2 Title * Tag 1 Post 3 Title * Tag 1 Post 4 Title HARDWARE * Tag 2 Post 1 Title * Tag 2 Post 2 Title * Tag 2 Post 3 Title * Tag 2 Post 4 Title CLEARANCE * Tag 3 Post 1 Title * Tag 3 Post 2 Title * Tag 3 Post 3 Title * Tag 3 Post 4 Title
Now that is a usable list of tags that makes the content readily available. A great side effect of displaying posts by tag frequency is that your site become much more dynamic. For example, maybe you go to a plumbing conference and blog 30 posts about it, all tagged Plumbing. The content on the site will automatically start displaying the posts tagged with Plumbing at the top of the list. I call it the “bubbling” homepage.
Enough rambling, here’s the code:
[php]
query(“tag={$tagRight->slug}&showposts=$noOfPosts”);
?>
have_posts() ) :?>
- name ?>
Hey Sandboxers, How About an Update! (OR How to Update the Sandbox Theme to Work With WordPress 2.7)
Note: This post is intended to be a little tongue-in-cheek although the author himself does not claim to be funny at all. Please read with your humor-glasses on.
Bump, bump. Hey Sandboxers, yeah you, Scott and Andy. WordPress 2.7 has been out for a while now and we still don’t have an update to Sandbox. I mean we’ve got sticky posts now, and threaded comments, and a new logout tag. I think it’s about time we had a talk.
I went and told all these nice folks to use Sandbox and we don’t even get a little logout love? It is the best theme out there, with all of its wonderfully plain goodness and classes-to-the-max and whatnot. I’d say it’s about time for version 1.7.
Oh, and while you’re at it how about updating the Drupal version too and hitting up the Movable Type guys about getting theirs in line with the changes. And why not add one single place to get Sandbox for ANY CMS out there. It could be a veritable template Mecca, but I digress.
It’s not like you have anything better to do anyway, right? Ok, I’ll make the first move, here’s how I did it in WordPress…
In basically every template file (404, archive, archives, attachment, author, category, image, index, links, page, single, and tag), replace
[php]
class=””
[/php]with
[php]
[/php]Ok so you lose all those date classes but the
hentry
is still there and now we’ve got stickies! Yay!The other order of business, is of course the logout link on the comment form. She don’t work. Is broke. We need to replace this:
[php]
get_bloginfo(‘wpurl’) . ‘/wp-login.php?redirect_to=’ . get_permalink()
[/php]with this:
[php]
wp_logout_url(get_permalink())
[/php]…presses Easy Button.
Ok, the last thing: threaded comments. That’s pretty cool stuff, but optional IMO. So imma leave that one to you guys. Okay okay it’s just because I’m too lazy to recode
comments.php
. But seriously the whole comments loop got some great changes that make all this stuff a heckofalot easier.So if you could please do that, k thx bye. 😉
On a more serious note, has anyone here tried out the new commenting loop? How are you implementing threaded comments in WordPress?
Bash Script for Updating Multiple WordPress Blogs
While WordPress has finally added core update in its latest 2.7 branch, there are still people out there that will need to update multiple blogs quickly, and if you are managing your blog installations with Subversion, you can go through and update them all very quickly.
Of course, to update multiple blogs, you’ll have to go through to each folder, run the proper Subversion command, and then move onto the next folder. This can be a time consuming process if you have more than five or six blogs to do for each release.
I have previously written a post on Geeks are Sexy about updating WordPress blogs with Subversion. Read that first if you aren’t using Subversion.
Bash Script
The easiest way to help automate simple tasks on a Linux web server is to Bash script it. This is a very simple scripting language that allows you to do commands and using simple looping and an array, you can quickly do those commands multiple times for multiple blogs.
When I was working for Bloggy Network, I used a similar script to upgrade upwards of forty WordPress powered blogs in less than five minutes.
The following script assumes that your blogs are all in sub-folders under where this script will be placed. If the blogs are in different locations, make sure to include that in your path determinations either when you assign array values or as another variable you can make use of.
[code]
#!/bin/bashblog[1]=foldername1
blog[2]=foldername2
blog[3]=foldername3for a in 1 2 3
do
echo “Giving ${blog[$a]} an Upgrade”
cd ${blog[$a]}
svn sw http://svn.automattic.com/wordpress/tags/2.7.1 .
cd ..
doneexit 0
[/code]This code basically creates an array, and then cycles through the array, going into each folder, and switching the blog to the latest version of WordPress. The only editing you’ll need to do to before using this script is change the blog variable, and change the tagged version number in the svn sw command. If you are using trunk, you don’t have to do this and instead of /tags/version.number you’d just put /trunk.
While I don’t recommend running on trunk, especially for your production blogs, I know many people that do.
If you add more items to the array, you have to make sure that you add more numbers to your for loop. So if there were ten items in the blog array, you would want to make sure to change the for a line to: for a in 1 2 3 4 5 6 7 8 9 10.
Bash scripting is a relatively simplistic language, but can be very powerful.
This script could be easily modified to include error checking, create a log file where you can look over which files were changed, and when they were last changed, and you could also make it so that when the script ran, it asked you for which version number to use in the switch command.
I have also used Bash scripting to upload the same plugins to a number of different blogs all at once, make edits to the .htaccess file, and delete certain files.
If you have access to your server and can run Bash scripts, I suggest you play around with them, as they can be a great tool when the right circumstances rear their ugly head.
How to Use WordPress for Bookmarking
After Ma.gnolia went down I was so disappointed that I decided to take matters into my own hands. I thought, why not use WordPress to store my bookmarks. It has all the neat features of most popular bookmarking sites, and even some more (XFN, for example).
Of course, I could just post a link whenever I saw one but it panged me to think that I would be putting to waste that wonderful link schema that the folks at WordPress have put so much thought into. And then Smashing Magazine reminded me about shortcodes. I had used them before in plugins but I never thought about just adding one off short codes to my
functions.php
file.It turns out that this was the perfect solution to my problem. With one tiny little shortcode I was able to utilize the bookmarks system in WordPress and publish my links as normal. Here is how I did it.
1. The shortcode code
First you want to start by adding the following code somewhere in your
functions.php
file.[php]
/**
* Get a bookmark and display it
*
* usage: [magnolia id=”bookmarkid”]
*
* @return string
*/
function magnolia_rip($atts) {
extract(shortcode_atts(array(
‘ids’ => ‘1’,
), $atts));$idarr = explode(‘,’,$ids);
$bookmarks = ”;foreach ($idarr as $id) {
$bookmark = get_bookmark($id,ARRAY_A);
extract($bookmark);$bookmarks .= <<
$link_notes
LINK;
}return $bookmarks;
}
add_shortcode(‘magnolia’, ‘magnolia_rip’);
[/php]I’ll skip the details on how shortcodes work, the Smashing Magazine post does a great job of summing that up. However, I do want to explain the bookmark stuff.
We start by passing in the id or comma separated list of ids through the shortcode. They get put into an array where they are iterated. For each id we call the
get_bookmark
method, which is currently undocumented. It returns an object or array with all the values from the links table in your WordPress installation. TheARRAY_A
parameter tells the method to return an associative array.Here are all the fields in the links table:
link_id
link_url
link_name
link_image
link_target
link_category
link_description
link_visible
link_owner
link_rating
link_updated
link_rel
link_notes
link_rss
I have used the extract() method to convert each key (field) in the returned array to a variable. That’s probably not the best idea for performance reasons, but for demonstrational purposes it’s nice and clean. Next, I create a div with some paragraphs and a link. This is the part where you can customize to your hearts content. I just went with something basic.
2. Add a link
Now all you need to do is head over to your links page in the WP admin and add a link. I put mine in a category called bookmarks just to keep things organized. You can go crazy here if you want. Once you’ve saved the link make sure to get the ID for it.
The ID isn’t anywhere obvious, unfortunately, which makes this technique feel a little hacky. Regardless, if you go back to the links page and hover over the title of your link you will see something like this in your status bar at the end of the URL:
[html]
link_id=165
[/html]Just take note of the id, you’ll need it for the next step.
3. Write your post
Finally, lets post the link to the blog using the shortcode we created earlier. Start a new post and add the following:
[html]
[magnolia ids=”165″]
[/html]That’s it! Now save your post and basque in the glory of your ingenuity!
Caveats
There is one caveat that I can think of. The RSS feed will not publish the generated text. So you’ll only have titles for those posts unless you add more text to the body of your post.This is a great way to use an often under-utilized feature of WordPress. It is also fun to host and publish your own bookmarks for people to see. Let me know how it works for you!
Update: After more careful testing I realized that the full text does, in fact, show up in RSS. So there you have it, if you want to post your bookmarks to your site nothing is standing in your way!
have_posts() ) : $postsRight->the_post(); ?>