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


echo "<br><br>".get_query_var('term');
echo "<br><br>".get_query_var('taxonomy');
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy') );
echo "<br><br>$term";


Array ( [titles] => windows-powershell-v2 [taxonomy] => titles [term] => windows-powershell-v2 ) 



As you can see, the first three lines run fine. The fourth line fails with no error - but it terminates page execution. The specified term does indeed exist in the taxonomy; this is being reached with the URL /titles/windows-powershell-v2/.

Any idea what I'm doing wrong?

share|improve this question
up vote 2 down vote accepted

get_term_by() returns object by default. Which should end up in Catchable fatal error: Object of class stdClass could not be converted to string if you try to echo it. Likely you have errors suppressed.

Try var_dump( $term ); instead of echo.

share|improve this answer
Yup. Finally figured that out just as you posted. Duh. That could be better-documented, but I wanted $term->name. – Don Jones Sep 17 '10 at 18:40
Most functions that deal with terms return objects, there are simply way more to term than name alone. Run test environment with define('WP_DEBUG', true); makes life much easier when you see errors. – Rarst Sep 17 '10 at 18:42

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.