Object std Class Error when using custom taxonomies
-
Hi,
I’m getting the object stdClass error for displaying a custom taxonomies and tags.
Fatal error: Cannot use object of type stdClass as array in /var/www/vhosts/default-domain.com/httpdocs/wp-content/themes/atlas-child/content-single-listing.php on line 364
I’m trying to display the images that are associated to the custom taxonomies, in the front end the user ticks the checkboxes that they offer, i.e. soccer, basketball etc, which would then appear as thumbnail images on their profile.
my code in my template looks like this :
<?php
$rows = get_field(‘bar_entertainment’);
$first_row = $rows[0];
$term_id = $first_row[‘bar_entertainment’][0]->term_id;
$args = array(
‘post_type’ => ‘attachment’,
‘post_status’ => ‘inherit’,
‘tax_query’ => array(
array(
‘taxonomy’ => ‘event-categories’,
‘field’ => ‘id’,
‘terms’ => array($term_id)
)
)
);
?>
<?php
$the_query = new WP_Query( $args );while ( $the_query->have_posts() )
{
$the_query->the_post();
echo wp_get_attachment_image( get_the_ID(), ‘thumbnail’);
}
wp_reset_query();?>
when a dump this is what I get:
array(3) {
[0]=> object(stdClass)#3289 (10) {
[“term_id”]=> int(689)
[“name”]=> string(13) “Europa League”
[“slug”]=> string(13) “europa-league”
[“term_group”]=> int(0)
[“term_taxonomy_id”]=> int(1105)
[“taxonomy”]=> string(16) “event-categories”
[“description”]=> string(19) “Europa League Match”
[“parent”]=> int(996)
[“count”]=> int(1)
[“filter”]=> string(3) “raw”
}
[1]=> object(stdClass)#3238 (10) {
[“term_id”]=> int(1017)
[“name”]=> string(12) “Sports Event”
[“slug”]=> string(12) “sports-event”
[“term_group”]=> int(0)
[“term_taxonomy_id”]=> int(1101)
[“taxonomy”]=> string(16) “event-categories”
[“description”]=> string(151) “Bars showing live sport events such as soccer, golf, basketball, American college conference, baseball, tennis, formula 1, rugby and world cup football”
[“parent”]=> int(0)
[“count”]=> int(1)
[“filter”]=> string(3) “raw”
}
[2]=> object(stdClass)#3287 (10) {
[“term_id”]=> int(638)
[“name”]=> string(21) “UEFA Champions League”
[“slug”]=> string(21) “uefa-champions-league”
[“term_group”]=> int(0)
[“term_taxonomy_id”]=> int(1104)
[“taxonomy”]=> string(16) “event-categories”
[“description”]=> string(27) “UEFA Champions League Match”
[“parent”]=> int(996)
[“count”]=> int(1)
[“filter”]=> string(3) “raw”
}
}The question is how do I get this to display the images or if I just want to display the names of the fields instead of returning the ids?
any help would be much appreciated. Thanks
- The topic ‘Object std Class Error when using custom taxonomies’ is closed to new replies.