[Resolved] Google Console Errors – Missing author/title/updated

  • Author
    Posts
  • #7932

    Reid
    Participant

    Hi Andrew,

    I noticed in Google Console that I have quite a few errors for missing author/title/updated. I found another thread in the support archives that recommended to install the code snippets plugin and cut/paste this code:

    if ( ! function_exists( ‘ultra_post_class_filter’ ) ) :
    /**
    * Filter post classes.
    * @link https://codex.wordpress.org/Function_Reference/post_class.
    */
    function polestar_post_class_filter( $classes ) {
    $classes[] = ‘post’;

    // Resolves structured data issue in core. See https://core.trac.wordpress.org/ticket/28482.
    if ( is_page() ) {
    $class_key = array_search( ‘hentry’, $classes );

    if ( $class_key !== false) {
    unset( $classes[ $class_key ] );
    }
    }

    $classes = array_unique( $classes );
    return $classes;
    }
    endif;
    add_filter( ‘post_class’, ‘ultra_post_class_filter’ );

    I also set to “Only run on site front-end” as recommended. When I finished, I received the following error information above each post on my live blog page:

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘ultra_post_class_filter’ not found or invalid function name in /home7/aixplori/public_html/wp-includes/class-wp-hook.php on line 300

    Warning: array_unique() expects parameter 1 to be array, null given in /home7/aixplori/public_html/wp-includes/post-template.php on line 545

    Warning: join(): Invalid arguments passed in /home7/aixplori/public_html/wp-includes/post-template.php on line 423
    class=””>

    I’ve deactivated so that the ugly errors do not display in my blog page (https://www.aixploringprovence.com/blog-journal/) until I hopefully have a solution. Do you have any advice as to what I may be doing wrong?

    Thanks.

    #7933

    Andrew Misplon
    Keymaster

    Hi Reid

    Thanks again for posting.

    That’s my fault, try the following instead:

    if ( ! function_exists( 'ultra_post_class_filter' ) ) :
    /**
    * Filter post classes.
    * @link https://codex.wordpress.org/Function_Reference/post_class.
    */
    function ultra_post_class_filter( $classes ) {
    	$classes[] = 'post';
    
    	// Resolves structured data issue in core. See https://core.trac.wordpress.org/ticket/28482.
    	if ( is_page() ) {
    		$class_key = array_search( 'hentry', $classes );
    
    		if ( $class_key !== false) {
    			unset( $classes[ $class_key ] );
    		}
    	}
    
    	$classes = array_unique( $classes );
    	return $classes;
    }
    endif;
    add_filter( 'post_class', 'ultra_post_class_filter' );
    #7934

    Reid
    Participant

    Great, thanks. Revised the code as instructed and the errors are no longer appearing. Will validate with console over the next few days to see if the crawl errors resolve. I appreciate all you help!

    #7935

    Andrew Misplon
    Keymaster

    Super, glad that helped.

    On your blog page and single post pages, the author, updated time and title are all there. The snippet you’ve used will hopefully allow Google to differentiate between pages and posts (syndicated content), thereby not expecting all that info from pages.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Scroll to top