Site logo

Archived topic

Error in the documentation of the generate_site_title_output filter

4 replies · Started by Nicolas on March 29, 2023

Viewing posts 1–5 of 5

Hi,
https://docs.generatepress.com/article/generate_site_title_output/
The tag and parameters 2 and 4 are missing.

$site_title = apply_filters(
			'generate_site_title_output',
			sprintf(
				'<%1$s class="main-title"%4$s>
					<a href="%2$s" rel="home">
						%3$s
					</a>
				</%1$s>',
				( is_front_page() && is_home() ) ? 'h1' : 'p',
				esc_url( apply_filters( 'generate_site_title_href', home_url( '/' ) ) ),
				get_bloginfo( 'name' ),
				'microdata' === generate_get_schema_type() ? ' itemprop="headline"' : ''
			)
		);

Hi there,

that is just an example of how to use the filter to remove the link from the title.
I must say its not a great example and has probably been there since before we updated the schema method.

I think for that example where only 3 params are required we could change it to:

add_filter( 'generate_site_title_output', function( $output ) {
	return sprintf(
		'<%1$s class="main-title" %3$s>
		    %2$s
		</%1$s>',
		( is_front_page() && is_home() ) ? 'h1' : 'p',
		get_bloginfo( 'name' ),
                'microdata' === generate_get_schema_type() ? ' itemprop="headline"' : ''
	);
});

What do you think ?

Hi David,
Ok this may be an example but the sprintf function tries to insert 3 parameters while there are only two in the string (%1$s and %3$s) ;-).
Nicolas.

Yeah its a bad example :)

Ill get it updated to the one i listed above.

FYI - we updated the example. Thanks again.

This archived topic is closed to new replies.