I need to make all html links of my wordpress website dont end in "?amp=1".
For example the link:
<a href="https://example.com/page-1/?amp=1">Page 1</a>
It should change to:
<a href="https://example.com/page-1/">Page 1</a>
I have added the following code to my functions.php file but unfortunately it doesn't work.
function remove_amptoamp_links(){
?>
<script type="text/javascript">
jQuery(document).ready(function($){
$('a').each(function(){
if(this.href.indexOf("?amp=1") != -1)
{
var href=this.href.split("?amp=1")[0];
this.href = href;
}
});
});
</script>';
<?php
}
add_action('wp_footer', 'remove_amptoamp_links');
Some help? Thanks!
I have finally discovered that AMP does not allow Javascript to be executed.