Been trying to chase down an error on this page:
Catchable fatal error: Object of class WP_Error could not be converted to string
I have a custom post type and taxonomy:
Taxonomy: team_categories
Term: "Committees" (among others)
Child terms under committees: Continuing Education, Ethics, Legislative Action, etc. (* this part seems to be working)
- Team members in each committee (not working)
I want to list the child terms on the "Committees" taxonomy template page and display the members of each committee, for instance:
Continuing Education committee
- Jane Doe
- John Brown
- etc.
Ethics committee
- Jack Jones
- Ann Acme
- etc.
Here is the current code:
$taxonomyName = "team_categories";
//This gets top layer terms only. This is done by setting parent to 0.
$parent_terms = get_terms(
$taxonomyName,
array( 'parent' => 0, 'orderby' => 'slug', 'hide_empty' => false )
);
echo '<ul>';
foreach ( $parent_terms as $pterm ) {
//Get the Child terms
$terms = get_terms(
$taxonomyName,
array( 'parent' => $pterm->term_id, 'orderby' => 'slug', 'hide_empty' => false )
);
foreach ( $terms as $term ) {
echo '<li><a href="' . get_term_link( $term->name, $taxonomyName ) . '">' .
$term->name . '</a></li>';
}
}
echo '</ul>';
The error appears to be here:
echo '<li><a href="' . get_term_link( $term->name, $taxonomyName ) . '">' .
$term->name . '</a></li>';
Update:
The following code gets me darn close to what i'm looking for:
$term_id = 26; // id of committees
$taxonomy_name = 'team_categories';
$termchildren = get_term_children( $term_id, $taxonomy_name );
echo '<ul>';
foreach ( $termchildren as $child ) {
$term = get_term_by( 'id', $child, $taxonomy_name );
echo '<li><a href="' . get_term_link( $child, $taxonomy_name ) . '">' .
$term->name . '</a></li>';
}
echo '</ul>';
It lists all of the sub categories in the "Committees" category.
How can I display each category's posts under each category heading? The custom post type's name is "team".