Bài viết này thực hiện (hoặc lụm bài về đăng câu like từ các trang khác) bởi Việt Lâm Coder một YOUTUBER có tâm và đẹp trai siêu cấp vô địch zũ trụ.
Sometimes we need to segregate different types of URL under some categories. Say for example you have a Woo Shop then you have /shop
to identify a product or you have custom post type say services then you have /service
, So now suppose we also need show all single blog posts under /blog
then to achieve this we simply have to change the Permalink Settings.
To do this first login into WordPress admin panel and then navigate to
Dashboard > Settings > Permalinks
Under Common Settings section select Custom Structure and set it to /blog/%postname%/
Now our single post page is setup, we now need to also add /blog
to category and tag archive page, to this we need to alter Optional section field value. Set blog/category
in Category base, and blog/tag
in Tag base.
That it! we have set everything without writing a single line of code.
Just one important note if we have any custom post_type
then we need to add with_front
to false
in rewrite
, for example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$labels = [ "name" => __('Services', 'text-domain'), //... //... ]; $args = [ "label" => __('Services', 'text-domain'), "labels" => $labels, //... //... "rewrite" => ["slug" => "service", "with_front" => FALSE], //<-- SET with_front to FALSE //... ]; register_post_type("service", $args); |
It’s that’s simple just a quick tips if we also need to add category name with blog
to blog single post then we need to set Custom Structure to /blog/%category%/%postname%/
.
Bài viết này thực hiện (hoặc lụm bài về đăng câu like từ các trang khác) bởi Việt Lâm Coder một YOUTUBER có tâm và đẹp trai siêu cấp vô địch zũ trụ.