Ready Designs

4 8-bit dragons in a line

Displaying Custom WordPress Taxonomy List Items Without the Links

Tutorials

April 21st, 2011

Or: How to Strip <A> Tags From get_the_term_list

Okay, this one is a bit obscure and not terribly complex, but it took me a minute to solve, so here it is for the rest of the world.

I was working on a WordPress custom taxonomy as a way to store and display useful information about a post. Specifically, I was creating a “Venue” type to store nightclub names which could then be displayed easily throughout the theme’s code, as well as inserted via shortcode.

Creating the Custom Taxonomy

Creating the taxonomy itself wasn’t really that hard, and isn’t the main subject of this post, but for the sake of completeness, I’ll cover that briefly first.

span class="st0">'your-custom-taxonomy-name', 'page''hierarchical''label'=>'Taxo Name', 'query_var''rewrite'

In the above code, I’m registering the taxonomy “your-custom-taxonomy-name” to attach to pages (as opposed to posts). I’m declaring it to be a hierarchical type, like WordPress’ native Categories, with the label “Taxo Name” showing up as the label above it in the admin. The “query_var” tells whether it should apply to custom post types, and “rewrite=>true” allows for pretty URLs such as “mysite.com/your-custom-taxonomy-name/item” instead of the default “mysite.com/?your-custom-taxonomy-name=item”.

This declaration in your functions.php file will register the taxonomy with the database and put a new meta box next to your pages.

For more info on custom taxonomies and how they work, check out custom taxonomies in the WordPress codex.

Outputting the Taxonomies Without Links

Now, I wanted to output the taxonomy info into the theme; i.e., I wanted the theme to display the name of the venue in various places. My only problem was that while the most obvious choice for this was WP function “get_the_term_list()“, it outputs the taxonomy terms as links, wrapped in <a> tags. After some mucking around, I discovered two possible solutions. Keep Reading

Happy Folks

    • Roxanne will grasp the bigger picture of any job and is one of those rare species that combines technical skill, creativity and functionality.

      Annelies Draaijer, Raglan Shire

    • Roxanne shows her skills in social media everyday by managing numerous accounts and keeping them updated to attract traffic. She's capable of creating an online presence and keeping it within the tone and attitude the company desires.

      William Kammer, BDI

    • When a concern comes up that she knows about, she's usually suggesting solutions before I even come to her to discuss the problem.

      William Kammer, BDI

    • I would hire Roxanne for another project anytime I have one and feel confident she would do a tremendous job.

      Rachael Masek, UWF Webspinners

    • Roxanne Rocks! Super quick turnaround, amazing communication and a pleasure to work with. She's the best and I highly recommend her for your website/design needs

      Andrea Morelli, Impetuous Style

    • [Roxanne] brings along creativity, pro-activeness, enthousiasm, a high level of skill and she will think outside of boxes. She's also a quick learner and a very pleasant person to work with.

      Annelies Draaijer, Raglan Shire

    • Roxanne is an extremely talented programmer. She is able to take an extremely complex storyboard and turn it into a beautiful website. There is no project too big or too small that she can't handle.

      Rachael Masek, UWF Webspinners

Ready Designs on LinkedIn

Flying Green Dragon