WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a taxonomy for example "country" and I want to simply display the term in the side bar eg. New Zealand. There is only one possible taxonomy per post so I don't need to create a list or anything. Any ideas?

share|improve this question

Check the properties of get_queried_object().

Sample code:

<?php # -*- coding: utf-8 -*-
 * Plugin Name: Current Term Widget

add_action( 'widgets_init', array ( 'Current_Term_Widget', 'register' ) );

class Current_Term_Widget extends WP_Widget
    public function __construct()
        parent::__construct( 'current_term', 'Current Term' );
    public function widget( $args, $instance )
        if ( isset ( get_queried_object()->taxonomy )
            && isset( get_queried_object()->name )
            return print $args['before_widget']
                . '<b style="padding:10px;border:3px solid red">'
                . get_queried_object()->name
                . '</b>'
                . $args['after_widget'];
    public static function register()
        register_widget( __CLASS__ );

Here is a screen shot for the archive of category Cat B from the test data:

enter image description here

To restrict the widget output to a taxonomy compare get_queried_object()->taxonomy with your registered taxonomy name.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.