5

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="<?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) {
4

Ooops easier than I thought!

function edit_the_permalink($html){
    $html = updateToPerfectURLs($html);
    return $html;
}
add_filter('the_permalink', 'edit_the_permalink');
| improve this answer | |
  • 1
    although perhaps add_filter('the_permalink', 'updateToPerfectURLs'); would be simpler – Tom J Nowell May 12 '14 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.