Site logo

Archived topic

Changing Sidebar h tags.

22 replies · Started by Anonymous on October 8, 2015

Viewing posts 16–23 of 23

Hi Tom!
Could it be that the "Footer Widget 3" is gone...?
The rest of them still works, just not #3.

Interesting: #3 is gone for me and 4 and 5 only show their default text when I try to use them and put something in there...

Solved. Sorry, don't know, what it was, but the effect disappeared.

Interesting - glad it's back to normal now :)

Hi guys!

For SEO reasons, I need to change my widgets tittles on the footer, from <h2> to div.
I'm on footer.php file, but I don't know how to add the documentation filter, neither in which part of the file should be placed. Also, I deduct that the code is written in order to get an <h4> for widget tittles, but my source code tells me that they are actually in <h2>.

What I see on my footer.php:

/**
 * Build our individual footer widgets.
 * Displays a sample widget if no widget is found in the area.
 *
 * @since 2.0
 *
 * @param int $widget_width The width class of our widget.
 * @param int $widget The ID of our widget.
 */
function generate_do_footer_widget( $widget_width, $widget ) {
	$widget_width = apply_filters( "generate_footer_widget_{$widget}_width", $widget_width );
	$tablet_widget_width = apply_filters( "generate_footer_widget_{$widget}_tablet_width", '50' );
	?>
	<div class="footer-widget-<?php echo absint( $widget ); ?> grid-parent grid-<?php echo absint( $widget_width ); ?> tablet-grid-<?php echo absint( $tablet_widget_width ); ?> mobile-grid-100">
		<?php if ( ! dynamic_sidebar( 'footer-' . absint( $widget ) ) ) : ?>
			<aside class="widget inner-padding widget_text">
				<h4 class="widget-title"><?php esc_html_e( 'Footer Widget', 'generatepress' );?></h4>
				<div class="textwidget">
					<p>
						<?php
						printf( // WPCS: XSS ok.
							/* translators: 1: admin URL */
							__( 'Replace this widget content by going to <a href="%1$s"><strong>Appearance / Widgets</strong></a> and dragging widgets into this widget area.', 'generatepress' ),
							esc_url( admin_url( 'widgets.php' ) )
						);
						?>
					</p>
					<p>
						<?php
						printf( // WPCS: XSS ok.
							/* translators: 1: admin URL */
							__( 'To remove or choose the number of footer widgets, go to <a href="%1$s"><strong>Appearance / Customize / Layout / Footer Widgets</strong></a>.', 'generatepress' ),
							esc_url( admin_url( 'customize.php' ) )
						);
						?>
					</p>
				</div>
			</aside>
		<?php endif; ?>
	</div>
	<?php
}

And here is what my source code prints:

<aside id="media_image-2" class="widget inner-padding widget_media_image"><h2 class="widget-title">My tittle text</h2><img width="170" height="249" src="https://MyPictureOnTheWidget.png" class="image wp-image-2244 attachment-full size-full" alt="More text" style="max-width: 100%; height: auto;" /></aside>

Is there any paragraph I could add to the php file to solve this?
Thank you in advance, have a nice weekend!

Hi there,

You just need to add this code to your site:

add_filter( 'generate_start_widget_title', function() {
    return '<h4 class="widget-title">';
} );

add_filter( 'generate_end_widget_title', function() {
    return '</h4>';
} );

You can add it using one of these methods: https://docs.generatepress.com/article/adding-php/

Note that we use <h2> elements by default for accessibility purposes.

Hi Tom,

Thank you so much for your quick answer (as always), this theme deserves not a 5 but a 6 stars rating! :)
I've just done it via code snippet, and it works great.

Thank you again. Have a nice day!

Glad I could help! :)

This archived topic is closed to new replies.