How to add #navbar to all page links?

I have several Wordpress websites with large images at their tops, using 2013 child theme.

How to add #navbar anchor to all page links, so that the browser scrolls down a bit, when a user clicks a link in the Pages widget?

(because otherwise users think that nothing has happened after they click, since they see the same big image again).

In the file wp-includes/widgets/class-wp-widget-pages.php I have found the source code for the WP_Widget_Pages, but I am not sure how to modify it the best way (it should probably happen in my twentythirteen-child theme too).

Topic theme-twenty-thirteen child-theme filters widgets menus Wordpress

Category Web


You can add a filter to page_link to modify link output:

function wpd_add_fragment_to_pages( $url ) {
    return $url . '#navbar';
}
add_filter( 'page_link', 'wpd_add_fragment_to_pages' );

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.