I would like to make a change to the URL’s in my href attribute across my while site when the_permalink is called.

For example:

<h2><a href="https://wordpress.stackexchange.com/questions/144125/<?php the_permalink()?>"

Can I use my functions.php file to call my custom functon which deals with the search and replaces in the URL’s

function updateToPerfectURLs($content) {

1
1

Ooops easier than I thought!

function edit_the_permalink($html){
    $html = updateToPerfectURLs($html);
    return $html;
}
add_filter('the_permalink', 'edit_the_permalink');

Leave a Reply

Your email address will not be published. Required fields are marked *