WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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'm opening my posts in an iframe, and I'm using get_the_category_list to list post's categories. The problem is that when a user clicks on the category link, it opens in the iframe. How can I set the target for these generated links to be "_parent"?

share|improve this question
up vote 1 down vote accepted

get_the_category_list runs it output through the filter the_category. You could hook in there and change whatever you like. Something like this should work (untested):

add_filter('the_category', 'wpse90955_the_category');
function wpse90955_the_category($cat_list)
    return str_ireplace('<a', '<a target="_parent"', $cat_list);

If you just need to have that list filter in certain spots, you can define the function above in a plugin or theme's functions.php, then add the filter, call get_the_category_list, and remove the filter.

// assume wpse90955_the_category was defined elsewhere and is already loaded
add_filter('the_category', 'wpse90955_the_category');
echo get_the_category_list($some_sep, $parents, $some_post_id);
remove_filter('the_category', 'wpse90955_the_category');
share|improve this answer
Thanks, this works. – Red Mar 15 '13 at 3:12

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.