I know the more sensible approach for this would be to rely on archives so that my URL for news would be:


However, due to how I am setting this up for the client to easily modify the content, I have created 3 news pages (each referencing 3 categories), inside each one, there is code to display the news listing for each category.

I would like to change the permalink for those pages so that instead of being:


The permalink is:


I have looked around and the hook page_link seems to be what I would like.

Here is my callback function (which I have verified gets called):

    public static function change_news_permalinks( $url, $post ) {  
        $url = "{$url}something/";
        return $url;

This is just a test, if this worked, then I would continue and write the conditions so that the change would only take place when it's one of those 3 pages.

However, regardless of what page I view, the permalink remains unchanged when the page loads.

Am I using this incorrectly or am I misinterpreting what this hook actually allows you to carry out?


1 Answer 1


page_link is not going to work as even though you change what it shows or uses, that's not going to be detected when the URL is accessed -- which requires handling to parse it during the request.

You could look at adding rewrites, or what is probably easier you could use try using something like this (or view their code to see how they do it): https://wordpress.org/plugins/custom-permalinks/

Here's how they are doing it: https://plugins.trac.wordpress.org/browser/custom-permalinks/trunk/frontend/class-custom-permalinks-frontend.php

  • Thanks for that, I was looking at the code and it's not simple stuff, it all happens inside parse_request and it's not just copy/paste change-change xD Will put this on the back-burner and think of Plan B instead, appreciate the response.
    – csaborio
    Mar 4, 2021 at 2:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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