Tuesday, December 6, 2022
Wp Tricks

Rewrite wordpress post url working example


Hello to all, welcome to In this post, I will tell you, how to Rewrite wordpress post url working example.

Here I am introducing the new chapter of my blog and that is called Wp Tricks.

Now I come to this post, first I will tell you very short story behind this post. last few days ago, I was searching for changing WordPress Post URL and only with WordPress Hooks and I just want to add “blog” in between my WordPress Post URLs and I have done with below code.

Here is the working code and you need to add this into your theme’s functions.php file very carefully:

function filter_post_link($permalink, $post) {
    //Using only for post but can use for other posts types too
    if ($post->post_type == 'post')
         return 'blog'.$permalink; // this code will add blog in my post ulrs

add_filter('pre_post_link', 'filter_post_link', 10, 2);
 This will Filters the permalink structure for a post before token replacement occurs.

For Working, please check this video:

If you have any query related to this post then feel free to ask.


Thank you

the authortherichpost
Hello to all. Welcome to Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 8, Angular 9, Angular 10, Angular 11, Angular12, Angular 13, Angular 14, Angular 15, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.