This is going to be dependent upon how you created the custom post type. If you actually just created a post type called book
and didn’t create any rewrites then all you have to do is link to /book
. There’s nothing amateur about doing it this way…that’s how WordPress is designed. The only thing I might suggest as a bit amateur (in a most helpful way though) is not adding a prefix to your post type.
You should try creating your post type something specific. Example: gd_book
. Then use rewrite to change the slug to book
. You can do this by adding this line to your $args:
'rewrite' => array('slug' => 'books'),
(make sure to visit your permalinks page in settings to refresh this though)
If you did add a rewrite when you created your CPT (or just now) then you’ll need to use that new slug.
your link would be www. gagdetssite .com/books.
Your code could be <a class="btn" href="/books">All Books</a>
if you put it in pages directly.
If you’re coding it as part of the project you could also use: get_post_type_archive_link('gd_book')
.