[Resolved] get property of non-object

Home Forums Support [Resolved] get property of non-object

Home Forums Support get property of non-object

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #743653
    Alain Aubry

    Hi
    I don’t visually see any problem, but when I enable “debug” I see 3 lines with the following texts:

    Notice: Trying to get property of non-object in /home/…/wp-content/plugins/wordpress-seo/frontend/class-frontend.php on line 717
    Notice: Trying to get property of non-object in /home/…/wp-content/plugins/wordpress-seo/frontend/class-frontend.php on line 720
    Notice: Trying to get property of non-object in /home/…/wp-content/plugins/wordpress-seo/frontend/class-breadcrumbs.php on line 399

    As these lines points to wordpress-seo, I opened a ticket at: https://wordpress.org/support/topic/get-property-of-non-object/
    After following their suggestions I found the fault at my “GeneratePress Child Theme”. It just happens in Author pages when the child theme is enabled, otherwise works fine.

    I am bringing this here in order to find some suggestions to diagnose, how to find the faulty script. I have a big amount of functions and actions in my functions.php, many recommended here or in some other sources.

    Thanks
    Alain

    #743993
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Do you have any functions in your child theme? If so, can you share them?

    #744077
    Alain Aubry

    Hi Tom
    I have lots of functions…
    They were tested individually before going live.
    The only place where the word author is found is here (two places):

    // GP Set CPT Image Positions
    add_filter( 'option_generate_blog_settings', 'indigo_cpt_options' );
    function indigo_cpt_options( $options ) {
    		if ( is_post_type_archive( array( 'actividade', 'colaborador', 'course' ) ) OR is_tax( array( 'grupo', 'tipo' ) ) OR is_search() ) {
    				$options[ 'masonry' ] = true;
    				$options[ 'infinite_scroll' ] = true;
    				$options[ 'post_image_padding' ] = false;
    				$options[ 'post_image_position' ] = 'post-image-above-header';
    				$options[ 'post_image_alignment' ] = 'post-image-aligned-center';
    				$options[ 'author' ] = false;
    				$options[ 'comments' ] = false;
        }
    		if ( is_post_type_archive( 'evento' ) ) {
    				$options[ 'masonry' ] = false;
    				$options[ 'infinite_scroll' ] = true;
    				$options[ 'post_image' ] = true;
    				$options[ 'post_image_padding' ] = true;
    				$options[ 'post_image_position' ] = 'below-title';
    				$options[ 'post_image_alignment' ] = 'left';
    				$options[ 'author' ] = false;
    				$options[ 'comments' ] = false;
        }
    		if ( is_singular( 'colaborador' ) ) {
    				$options[ 'single_post_image' ] = true;
    				$options[ 'single_post_image_padding' ] = true;
    				$options[ 'single_post_image_position' ] = 'below-title';
    				$options[ 'single_post_image_alignment' ] = 'left';
    				$options[ 'author' ] = false;
    				$options[ 'comments' ] = false;
        }
    		return $options;
    }
    // End GP Set CPT Image Positions
    

    and

    // Insert Yoast WPSEO Breadcrumbs */
    add_action( 'generate_before_main_content', 'indigo_breadcrumbs' );
    function indigo_breadcrumbs() {
    		if ( function_exists( 'yoast_breadcrumb' ) && is_single() && 'lesson' !== get_post_type() ) : // && 'lesson' !== get_post_type() && ! is_author()
    				yoast_breadcrumb( '<div class="inside-article"><p id=”breadcrumbs”>', '</p></div>' );
    		endif;
    }
    // END Insert Yoast WPSEO Breadcrumbs */
    

    This second one ‘author’ is in a comment…

    Thanks
    Alain

    #744080
    Alain Aubry

    I am planning disabling all the “actions” one by one, as I did with the plugins.

    #744320
    Tom
    Lead Developer
    Lead Developer

    That’s a good idea – let me know if you can pinpoint the function 🙂

    #746175
    Alain Aubry

    OK, I found the function that causing the problem, but it does not make any sense.
    I am going the share the faulty function:

    
    // Indigo Adjust Main Queries
    add_action( 'pre_get_posts', 'indigo_adjust_queries' );
    function indigo_adjust_queries( $query ) {
    	if ( !is_admin() && is_post_type_archive( 'actividade' ) && $query->is_main_query() ) :
    		$query->set( 'post_per_page', -1 );
    		$query->set( 'orderby', 'post_modified' );
    		$query->set( 'order', 'DESC' );
    	endif; // actividade
    
    	if ( !is_admin() && is_post_type_archive( 'colaborador' ) && $query->is_main_query() ) :
    		$query->set( 'post_per_page', -1 );
    		$query->set( 'orderby', array(
    			'relation' => 'AND',
    			array(
    				'orderby' => 'menu_order',
    				'order', 'ASC'
    			),
    			array(
    				'orderby' => 'post_title',
    				'order', 'ASC'
    			)
    		));
    	endif; // colaborador
    
    	if ( !is_admin() && is_post_type_archive( 'evento' ) && $query->is_main_query() ) :
        $today = date('Ymd');
    		$query->set( 'post_per_page', -1 );
    		$query->set( 'post_type', 'evento' );
        $query->set( 'meta_key', 'data_do_evento' );
        $query->set( 'orderby', 'meta_value_num' );
        $query->set( 'order', 'ASC' );
        $query->set( 'meta_query', array(
          array(
            'key' => 'data_do_evento',
            'compare' => '>=',
            'value' => $today,
            'type' => 'numeric'
          )
        ));
    	endif; // evento
    
    	if ( !is_admin() && is_post_type_archive( 'course' ) && $query->is_main_query() ) :
    		$query->set( 'post_per_page', -1 );
    		$query->set( 'orderby', 'post_modified' );
    		$query->set( 'order', 'DESC' );
    	endif; // course
    
    	$term = single_term_title( '', false );
    	if ( $term ) :
    		if ( !is_admin() && is_tax( 'grupo' ) && $query->is_main_query() ) :
    			$query->set( 'post_per_page', -1 );
    			$query->set( 'post_type', 'colaborador' );
    			$query->set( 'orderby', 'menu_order' );
    			$query->set( 'order', 'ASC' );
    			$query->set( 'tax_query', array(
    				array(
    					'taxonomy' => 'grupo',
    					'field' => 'name',
    					'operator' => 'IN',
    					'terms' => $term
    				)
    			));
    		endif; // colaborador
    
    		if ( !is_admin() && is_tax( 'tipo' ) && $query->is_main_query() ) :
    			$query->set( 'post_per_page', -1 );
    			$query->set( 'post_type', 'actividade' );
    			$query->set( 'orderby', 'post_modified' );
    			$query->set( 'order', 'DESC' );
    			$query->set( 'tax_query', array(
    				array(
    					'taxonomy' => 'tipo',
    					'field' => 'name',
    					'operator' => 'IN',
    					'terms' => $term
    				)
    			));
    		endif; // actividade
    	endif; // terms
    
    } // END indigo_adjust_queries
    

    I will continue splitting this function into parts, maybe I can find it…

    Thanks

    #746277
    Alain Aubry

    Something is wrong here:
    $term = single_term_title( '', false );

    #746370
    Tom
    Lead Developer
    Lead Developer

    I’m not sure what would trigger that warning in Yoast SEO, unfortunately. Have you shared the problem function with them?

    #746481
    Alain Aubry

    They closed my ticket as resolved previously, as the problem is located in my child theme I agreed in closing. I will share again.

    It is shared here:
    https://wordpress.org/support/topic/get-property-of-non-object/#post-10940723

    They have an open ticket in Github:
    https://github.com/Yoast/wordpress-seo/pull/10905

    #746588
    Alain Aubry
    #746881
    Tom
    Lead Developer
    Lead Developer
    #747039
    Alain Aubry

    Yes, the solution is working, I only tried local.
    Thank you for being present and supportive…

    #747268
    Tom
    Lead Developer
    Lead Developer

    Great to hear 🙂

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.