I have successfully created a custom taxonomy in WordPress, and I created a page that lists all of the posts under a specified taxonomy, with a file named taxonomy.php. It works, but some of the php isn’t printing any text. The page seems to churn out some php errors with error reporting turned on:
Notice: Undefined variable: term_name in WEBSITE_ROOT/themes/starkers/taxonomy.php on line 24
The variable is $term_name. Here is the code I have in my taxonomy.php page. I followed this tutorial. I thought I followed the tutorial pretty well.
<?php
get_header(); ?>
<?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); ?>
<h1><?php
printf( __( 'Posts classified under: %s', 'starkers' ), '<span>' . $term_name . '</span>' );
?></h1>
<?php
$category_description = category_description();
if ( ! empty( $category_description ) )
echo '' . $category_description . '';
get_template_part( 'loop', 'category' );
?>
<?php get_footer(); ?>
Basically, it’s not printing the taxonomy name after “Posts classified under:”
I tried fiddling around with the code, but no luck. If it helps, here is the code I used for functions.php to registering the taxonomy:
add_action( 'init', 'build_taxonomies', 0 );
function build_taxonomies() {
register_taxonomy(
'quotees',
'post',
array(
'hierarchical' => false,
'label' => 'quotees',
'query_var' => true,
'public' => true,
'rewrite' => true
)
);
}
If you look in the comments, apparently
$term_nameshould be$term->name. In fact, most of the$term_blahsshould be$term->blah.