You could do it with jQuery:
jQuery(document).ready(function($) {
$('a[href*=#]').on('click', function(event){
event.preventDefault();
});
});
Save that to a file (something.js) and upload it to your server. Then add the following to your functions.php (remember to set up a child theme if you aren’t using one):
add_action( 'wp_enqueue_scripts', 'prefix_load_scripts' );
function prefix_load_scripts() {
wp_register_script( 'something', get_stylesheet_directory_uri() . '/path/to/file/something.js', array('jquery'), true );
wp_enqueue_script( 'something' );
}
Related Posts:
- How to Change 404 page title
- How to build custom WP admin with custom URLs
- Adding Custom Link anchors in the top menu that points to specific sections of the site home page
- Create subpage /user/ or /my-profile/ like /author/ with additional query like /user/user123
- How to change URL Custom Page?
- Passing page url into a custom field via the Press-This bookmarklet
- Add filename to attachment page url
- add_rewrite_rule won’t work
- How can I get the page url slug when ‘post_name’ returns an id?
- How can I get the intended URL in a 404?
- Creating Search Engine Friendly URL’s with Word Press
- How to change the category url jusy show /category/%category_id% in wordpress?
- change url for static files in /wp-admin with a cdn url
- Many Rewrite Parameters/Rules
- title tag function
- query variables for custom taxonomies
- New to WP: links on static homepage are not working
- I want to change url structure of my created archieve pages
- URL issue after setting up Custom Structure in Settings >> Permalinks
- How to assign a default/priority taxonomy to be shown in url in case two taxonomy items are selected
- Replace an URL with an new URL which has a “?” in it
- Page Permalinks: Custom URLs
- Call a duplicate registration form with other url
- Pass query param to custom page
- New WP_Customize API – how does it work under the hood?
- Data sanitization: Best Practices with code examples
- Prevent WordPress from automatically installing a new theme each year
- Can we use one WordPress installation for multiple databases, domains and content directories
- how to override woocommerce specific loop or archive-product.php [closed]
- How to Add Customizer Setting in Child Theme
- When adding a custom REST endpoint, where do you put the endpoint function, and where do you put the function registration call?
- global menus made from master site’s custom menus wpmu network
- Capability to edit own posts and not others
- Is there a way to create invisible pages?
- How to handle security on a wordpress site? [closed]
- Which freelance sites are recommended to find WordPress developers/programmers, etc
- Count widgets of a certain type
- Custom widget select options needs to stay selected after save
- Syncing Avatars across multisite
- How to move the wordpress site from test url to main url? [duplicate]
- Creating user relationships
- Loop through custom fields with similar label / common chars in label
- title, content, feature images
- How can I make site-wide content editable, for example footer content
- Custom Facebook share button with custom title,url,image in wordpress
- Sort posts by multiple meta key values
- How Do I Remove The Right Hand Block On The Main Header?
- Category selectable homepage
- Create custom dashboard for Multisite admins
- Integrate wordpress into index page
- Highlight comments of all the site authors
- Development environment
- Allow guests to use WP Customizer but disable save button
- Can I add/replace the WordPress image in the Dashboard
- Add content in between of foreach
- How to insert a writing panel between the title and the page content?
- Woocommerce product permalink not working
- Show custom message/info for authors in add/edit post page
- I w’d like to know If there are simple solutions to integrate other CMSs to wordpress
- add_feed rewrite overwriting standard permalinks
- Create a page that dynamically loads data
- Editing a post template
- Gravity Forms – gform_field_value – query custom table breaks functions.php
- Customizer – How to get theme mod range value?
- Let author add field to metabox by pressing a button
- Usage of custom post types in a custom admin menu
- How to set up conditionals in page templates?
- How do I change my permalink structure to a custom structure on an established blog?
- Customize Widget Navigation
- I found this code to be very useful, how can I change it to a text that display “Product versions and period of last update” rather than a button?
- Select input in metabox not updated
- display text generated via custom get query string
- Add admin page for specific post status (for example)
- Bootstrap slider not working
- Custom Meta Box: Value saved in WordPress DB, but not shown in input field on Edit Screen
- Custom post-type working except for Selecting page-parent
- How could I change contact details in the footer?
- Editing a website made with wordpress
- How do I make elements in mobile only reverse order?
- Cannot replace header & footer using “the_content”
- Custom Route Returns 301/Passing Variable from Input
- Menu selection for header
- How to display custom admin pointers (tips/notifications) in Dashboard until dismissed?
- Custom password set/reset link in same URL format as default does’t work
- Two color in one Heading
- Creating custom setting in add media popup
- Still desperate about multiple TinyMCEs in widgets – is there any good solution to this yet?
- Expressions and str_replace
- How to create a new blog in wordpress?
- Best way to move a site to a subfolder for testing purposes?
- Wonderflux Framework Static Homepage
- Integrate non-wordpress site into a wordpress site
- Taxonomy template by post type
- Pass the post ID
- Need Advice to Working with Custom Post Meta
- If I want social media icons that link to my site’s corresponding accounts, is that better to do with a plugin, or manually?
- why jquery is not loading in wordpress page?
- Will too many overridden css rules lead to performance issues
- use another theme for just one page
- Custom Search on media files PDF images pages posts