I would like to know if I can have a page in WP that works like archive.php
for my custom post type.
I would like that it works like when in Settings -> Reading
I choose an static page like Posts page
.
Thank you!
I would like to know if I can have a page in WP that works like archive.php
for my custom post type.
I would like that it works like when in Settings -> Reading
I choose an static page like Posts page
.
Thank you!
Share Improve this question edited Jun 30, 2019 at 14:07 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Jun 28, 2019 at 9:13 fcastillofcastillo 992 bronze badges 4 |1 Answer
Reset to default 0One option is to set has_archive
to false
when you register the CPT. Then, create a Page with the same slug. So if your CPT is "mycpt" then create a Page at http://example/mycpt/.
From there, set up a custom Page template to act like an archive, but you can also (optionally) add content in the Page itself to appear above or below the individual CPT posts. You'll also be able to add all the regular Page attributes like postmeta.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745357776a4624219.html
has_archive
set totrue
, then these get created dynamically. Go tohttp://yourdomain/post-type-slug
and you'll see it. The template that's used will be determined by the template hierarchy. Is that what you're after? – Jacob Peattie Commented Jun 28, 2019 at 9:18