Archived topic
Showing custom post type in the front end
5 replies · Started by Vish on February 14, 2022
Hello!
Q1.
I have a custom post type called 'Books' and the url for this custom post type is like this: https://example.com/books.
Now, when I visit the link, it throws a 404 stating the page does not exist.
Q2.
And I have a category for the above custom post type called 'Non Fiction'.
When I Visit the link for the above category https://example.com/category/non-fiction, it simply shows a dummy page like this: https://cln.sh/6HpvYJ
Note: I created a content-template block to display the posts on the post type "Books" (if that detail makes any difference).
Selected the display rules as "Book category > Non Fiction".
How to fix these issues? Do I need to add any code for both of these pages to work?
Hi there,
have you set your CPT to support archives? See here:
https://generatepress.com/forums/topic/cpt-and-taxonomies-how-to-build-archive-pages/#post-1822578
Hello David
Thanks! Turns out the setting you mentioned was not enabled. Now I have enabled the same. That helped a little bit.
Now, the archive page is showing up as expected with the block template I had designed and set via elements.
But, the category URL is still showing up empty. I have provided the link too in case if you want to take a look. I have set the same block template as the Archives to "Category Archive" as well.
What am I missing?
In the Display Rules is there one labelled your_cpt_slug category archive
David, the custom taxonomy was not properly registered and I fixed it. That fixed the posts displaying issue.
As always, thanks a LOT for the quick help.
Glad to hear that!