Link to post type archive

If you want to link to the archive page of a custom post type you need the following code:

<?php $post_type = get_post_type_object( get_post_type($post) ); ?> <a href="<?php echo get_post_type_archive_link( get_post_type($post) ); ?>"><?php echo $post_type->label ; ?></a>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s