• Resolved DreamOn11

    (@dreamon11)


    Hello,

    Is there a way to configure The SEO Framework to add <meta name=”author” content=”xxx”> in <head>?

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    I don’t think this tag is supported by any platform or browser. Other SEOs even deem it useless. We supplement authorial information using the WebPage structured data via TSF and Articles structured data via one of our aptly named extensions.

    Still, you could use a filter if you wish to add this metadata. I think this will do, but I haven’t tested it:

    add_filter(
    	'the_seo_framework_meta_render_data',
    	function ( $tags_render_data ) {
    
    		if ( is_singular() ) {
    			$author_id = tsf()->query()->get_post_author_id(); // This verifies if the post supports authors.
    
    			$author_name = $author_id 
    				? get_userdata( $author_id )->display_name
    				: '';
    
    			if ( strlen( $author ) )
    				$tags_render_data['author'] = [
    					'attributes' => [
    						'name'    => 'author',
    						'content' => $author_name,
    					],
    				];
    		}
    
    		return $tags_render_data;
    	},
    );

    (Where do I place filters?)

    Thread Starter DreamOn11

    (@dreamon11)

    Thanks for help @cybr.

    I noticed this because I use Notion and when you mention a page, it manages to retrieve the author of page that you mentioned, this works for sites with YOAST but not with TSF.

    I guess it’s because of the meta author tag but I might be wrong.

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi again!

    Thanks for explaining where you use it. I’ll try it out later.

    I noticed I made a typo in my snippet, so it didn’t work.
    This updated version is tested and works as I would implement it into TSF itself:

    add_filter(
    	'the_seo_framework_meta_render_data',
    	function ( $tags_render_data ) {
    
    		$tsfquery = tsf()->query();
    
    		if ( $tsfquery->is_single() ) {
    			$author_id = $tsfquery->get_post_author_id(); // This verifies if the post supports authors.
    
    			if ( $author_id ) {
    				$tags_render_data['author'] = [
    					'attributes' => [
    						'name'    => 'author',
    						'content' => get_userdata( $author_id )->display_name ?? '',
    					],
    				];
    			}
    		}
    
    		return $tags_render_data;
    	},
    );

    Could you implement it and see if Notion now grabs the author’s name correctly? You might need to mention a page you haven’t before in Notion because they might have cached responses from other pages earlier.

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