Archived topic
switch tagline and title?
10 replies · Started by morriscountynj on April 21, 2021
Is there any way to switch around the tagline and the title, so that the tagline actually appears on the page first? :)
Hi there,
Any chance you can link us to the site in question?
You can use the private information field.
Let me know :)
Oh definitely! Here you go: https://mcscd.org/
Give this CSS a try:
.site-branding {
display: flex;
flex-direction: column;
}
.site-description {
order: -1;
}
Let me know :)
Sadly it didn't work!
But wouldn't that be non-accessible anyways, since the source order and visual order would differ?
in the old (floats) version i'd used this code:
<?php do_action( 'generate_before_header_content'); ?>
<?php generate_construct_logo(); ?>
<?php if ( empty( $generate_settings['hide_title'] ) || empty( $generate_settings['hide_tagline'] ) ) : ?>
<div class="site-branding">
<?php if ( empty( $generate_settings['hide_tagline'] ) ) : ?>
<p class="site-description"><?php bloginfo( 'description' ); ?></p>
<?php endif; ?>
<?php if ( empty( $generate_settings['hide_title'] ) ) : ?>
<p class="main-title" itemprop="headline"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
<?php endif; ?>
</div>
i switched to flexbox, and it didn't work properly. so thought there might be a new way to do it?
The CSS should work:
https://www.screencast.com/t/Kcve0Tbz4rsB
When you try some code, make sure you clear your cache to see the result. :)
Ah fair enough. It does work, but it's not accessible because the source and view order is different, correct? Is there a more accessible solution you're aware of?
Not sure if this really matter for accessibility but you can try this PHP snippet to reverse the order of title and description:
add_filter( 'generate_site_branding_output', function() {
// Get the title and tagline.
$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"' : ''
)
);
$site_tagline = apply_filters(
'generate_site_description_output',
sprintf(
'<p class="site-description"%2$s>
%1$s
</p>',
html_entity_decode( get_bloginfo( 'description', 'display' ) ), // phpcs:ignore
'microdata' === generate_get_schema_type() ? ' itemprop="description"' : ''
)
);
return sprintf(
'<div class="site-branding">
%1$s
%2$s
</div>',
( ! $disable_tagline ) ? $site_tagline : '',
( ! $disable_title ) ? $site_title : ''
);
} );
Adding PHP: https://docs.generatepress.com/article/adding-php/
that did it! thanks so much :)
(doing it via php means that the visual order AND source order are the same ^_^)
No problem :)