Search code examples
phpwordpressnotice

Notice: Trying to get property of non-object in /var/www/vhosts/braenworks.com/httpdocs/wp-includes/taxonomy.php on line 3950


Hi I am trying to solve a problem in my wordpress site https://braenworks.com/braenworks-academy/

There is a error at the top of my page :

Notice: Trying to get property of non-object in /var/www/vhosts/braenworks.com/httpdocs/wp-includes/taxonomy.php on line 3950

I think it is coming from the plugin learnpress because when I link the plugin to another page the error then appears on that page and moves away from the page where it previously stood.

This is the code on line 3950: elseif ( $t->query_var )

if ( empty($termlink) ) {
    if ( 'category' == $taxonomy )
        $termlink = '?cat=' . $term->term_id;
    elseif ( $t->query_var )
        $termlink = "?$t->query_var=$slug";
    else
        $termlink = "?taxonomy=$taxonomy&term=$slug";
    $termlink = home_url($termlink);

Can someone maybe help me with this :(?

Thanks!


Solution

  • Hard to say for sure but the following should get rid of the error. Change that elseif statement to this:

    elseif (isset($t) && is_object($t) && $t->query_var )
    

    The other thing you could do is turn off PHP errors which should be set to off for production anyway :)