Create a list of categories and tags in WordPress

This is more for personal use I suppose. Once upon a time, I needed to create a unified list of categories and tags for a post. I went about it the wrong way, getting all of the terms  for both, merging them using array_merge() and then looping through the list to get generate an unordered list. There is a simpler way…

[php title=”Create combined list of tags and categories”]
<?php
$terms = get_the_terms( $sched_post->ID, array( ‘category’, ‘post_tag’ ) );
if (!empty($terms)) {
$output .= ‘<li>Topics: ‘;
$the_terms = ”;
foreach ($terms as $idx => $term) {
$the_terms .= ‘, <a href="’ . get_term_link( $term ) . ‘">’ . $term->name . ‘</a>’;
}
$output .= substr( $the_terms, 2 );
$output .= ‘</li>’;
}
[/php]

The documentation for get_the_terms() used to say that you could only pass in a string of the taxonomy name. It is possible to pass in an array, and get an ordered list of terms back from all taxonomies. I’ve updated the documentation in the WordPress.org Codex to reflect this. Kinda neat. You don’t always need to have categories and tags together, but this saves merging/sorting and so forth.

You can see this in action on Maker Faire profile pages, like Todd Blatt.

Another related trick that I found the other day was using strip_tags() along with get_the_term_list(). I needed to output the names of a taxonomy without links. Rather then using get_the_term, and then looping through the names, like in the function above, I just ran strip_tags() and got the HTML that I was looking for. Boom!

[php title=”Strip tags from taxonomy list”]
echo strip_tags( get_the_term_list( get_the_ID(), ‘location’ ) );
[/php]

Any other taxonomy tricks?

Install Facebook Home on Nexus 4

Facebook Home on Nexus 4

In (eager) anticipation of getting Google Glass on Saturday, I ordered up a fancy schmanzy Google Nexus 4. I wanted to try out Facebook Home but was disappointed that it wasn’t inline with the supported devices. Luckily, there are some enterprising folks out there that have gone through the difficult work of opening up the software to other phones.

You can install Facebook home in three simple steps.

  1. Remove all Facebook apps that are currently installed on your phone.
  2. Download this zip file, and transfer contents to phone.
  3. Using an app like APK Installer, install the three apps in this order:
    1. com.facebook.katana.apk
    2. com.facebook.home.apk
    3. fborca243.apk

After that, you are all set! Launch Facebook, and allow it to take over the home screen. Pretty cool, and a nice new Android interface.

via XDA Developers