Categories

Thursday, April 18, 2024
#919814419350 therichposts@gmail.com
Wp Tricks

Rewrite wordpress post url working example

Hello to all, welcome to therichpost.com. 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 https://therichpost.com/blog/post-title

     }
}
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.

Jassa

Thank you

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 14, Angular 15, Angular 16, Angular 17, 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.