I've registered a custom post type named portfolio
and have coded it's respective archive-portfolio.php
file. Now, my requirement is to make this page available to be set as front page. For which I want to adopt the same approach as WooCommerce has adopted, it allows us to assign any static page to products archive page one time and then afterwards we can easily set/unset that page as our front page anytime without any extra step.
I know there are some solutions floating around like this: How to use a custom post type archive as front page?
If I adopt the above-mentioned solution, It'll work but if I decide to change my front page afterwards to something else I'll have to remove/disable this code, in addition. Whereas, in the case of WooCommerce, I don't need this extra step.
My question: How to set archive-portfolio.php
as my front page in the same way as WooCommerce allows us to set archive-product.php
as home page (i.e. without extra step)?
archive-product.php
only one time afterwards that static page can be set/unset as front-page without any additional step afterwards, Whereas, the solution linked above requires to do an additional step (adding/removing relevant code) every time we want to set/unset our archive page.page_on_front
toyour_archive_page
, that would duplicate the Woocommerce behavior. You need to add some way to set that option though, the same way Woocommerce does.