Hello Barry,
Today I tried a fresh install of TEC 3.2 on a copy of WP I’ve been using for a while, which just has the Twenty-Thirteen theme and a bunch of standard plugins I use all the time. It worked fine and I was able to create event categories (and sub-categories), assign those categories to event posts, and then view the event category pages in month and list mode without issue.
I think it might help you to read through the issue that I’m having however, as there may be something that’s been overlooked. Whether I look at an events category page that has any events assigned to it or not, I’m still getting the same error – it’s not related to there being no events to display as far as I can tell.
On the site that I’m still having issues with, I can view an events category page (e.g <domain.com/events/category/<event-category>/) in month layout just fine, but if I switch to list view I get the following error in set_notices() inside lib/tribe-template-factory.php on line 265:
TribeEvents::setNotice( 'events-not-found', sprintf( __('No matching events listed under %s. Check out upcoming events for this category or view the full calendar.', 'tribe-events-calendar') . $tax_term ) )
It seems that $tax_term
is expected to be a string, since it is initialised as one at the top of the function:
$tax_term = '';
This variable is then assigned a value in only one place, and only if this condition evaluates as true:
$tribe->get_event_taxonomy()
Which it does in my case, or else I wouldn’t be getting my error about object to string conversion. Within this conditional, the following assignment is made:
$tax_term = get_term_by( 'slug', get_query_var( 'term' ), $tribe->get_event_taxonomy() );
The WordPress codex states that the output for get_term_by can be either OBJECT, ARRAY_A, or ARRAY_N, with a default of OBJECT. Since $output
is set by parameter 4 (which is not present in this case) then we must assume the returned value is going to be an object.
That’s all fine, but the code that comes later (and that is responsible for the error) prints a message using sprintf, which assumes $tax_term
will be a string.
I was able to hack a fix by assigning before the problem code:
$tax_term = $tax_term->name;
This obviously assigns the string object variable to $tax_term
, but I get the feeling something is missing here. Maybe I’ve misunderstood something?
Thanks for your help