您可以使用jQuery执行此操作:
jQuery(document).ready(function($) {
    $(\'a[href*=#]\').on(\'click\', function(event){     
        event.preventDefault();
    });
});
 将其保存到一个文件(something.js)并上传到服务器。然后将以下内容添加到函数中。php(记住设置
child theme 如果您没有使用):
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\' );
}