{"id":481,"date":"2022-02-21T07:52:02","date_gmt":"2022-02-21T07:52:02","guid":{"rendered":"https:\/\/demo.wpartisan.net\/developmentsite\/what-is-the-default-archive-url-for-a-custom-post-type-and-how-can-we-modify-this-archive-url\/"},"modified":"2024-11-04T03:33:35","modified_gmt":"2024-11-04T03:33:35","slug":"what-is-the-default-archive-url-for-a-custom-post-type-and-how-can-we-modify-this-archive-url","status":"publish","type":"quick-tips","link":"https:\/\/demo.wpartisan.net\/developmentsite\/what-is-the-default-archive-url-for-a-custom-post-type-and-how-can-we-modify-this-archive-url\/","title":{"rendered":"What is the default archive URL for a Custom Post Type and how can we modify that archive URL?"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">When we register a post type using register_post_type() function, we need to pass two parameters with this function like this: register_post_type( string\u00a0$post_type, array|string\u00a0$args\u00a0=\u00a0array()\u00a0). To get an archive URL for the post type, we need to pass &#8216;has_archive&#8217; to True in the $args array.<\/p>\n\n\n\n<pre class=\"wp-block-code \\&quot;wp-block-code\\&quot;\"><code lang=\"\\&quot;php\\&quot;\" class=\"language-\\&quot;php\\&quot;\">register_post_type('quick-tips',\n    array(\n      ....\n      'has_archive' => true,\n      ....\n    )\n  );<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then your default archive URL will be like this: https:\/\/{your_site_url}\/quick-tips\/.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now if you want to modify your default archive URL, we need to pass another argument in the $args array like this:<\/p>\n\n\n\n<pre class=\"wp-block-code \\&quot;wp-block-code\\&quot;\"><code lang=\"\\&quot;php\\&quot;\" class=\"language-\\&quot;php\\&quot;\">register_post_type('quick-tips',\n    array(\n      ....\n      'has_archive' => true,\n      'rewrite' => array(\n        'slug' => 'tips-and-trick'\n      ),\n      .....\n    )\n  );<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then your quick-tips Custom Post Type archive URL will be like this: https:\/\/{your_site_url}\/tips-and-trick\/.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a Custom Post Type name quick-tips. Here I can show you what will be the default archive URL for this post type, and if we want to rewrite\/modify this archive URL, then how can we achieve this?<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}}},"tags":[17,39],"topics":[48,49,45],"class_list":["post-481","quick-tips","type-quick-tips","status-publish","hentry","tag-seo","tag-url","topics-html","topics-php","topics-wordpress"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"WPArtisan","author_link":"https:\/\/demo.wpartisan.net\/developmentsite\/author\/developmentsiteauth\/"},"uagb_comment_info":0,"uagb_excerpt":"I have a Custom Post Type name quick-tips. Here I can show you what will be the default archive URL for this post type, and if we want to rewrite\/modify this archive URL, then how can we achieve this?","_links":{"self":[{"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/quick-tips\/481","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/quick-tips"}],"about":[{"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/types\/quick-tips"}],"author":[{"embeddable":true,"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/comments?post=481"}],"wp:attachment":[{"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/media?parent=481"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/tags?post=481"},{"taxonomy":"topics","embeddable":true,"href":"https:\/\/demo.wpartisan.net\/developmentsite\/wp-json\/wp\/v2\/topics?post=481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}