Make WordPress Core

Opened 9 years ago

Closed 7 years ago

#34428 closed enhancement (wontfix)

New function `has_archive_post_type()`

Reported by: sebastianpisula's profile sebastian.pisula Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords:
Focuses: Cc:


Function will be check that custom post type has archive. For example:

<?php if(has_archive_post_type('cpt')) : ?>
<a href="<?php echo get_post_type_archive_link('cpt');?>">My Special Archive Link</a>
<?php endif;?>

Attachments (1)

34428.patch (854 bytes) - added by sebastian.pisula 9 years ago.

Download all attachments as: .zip

Change History (3)

#1 @swissspidy
9 years ago

get_post_type_archive_link returns false when a post type doesn't have an archive. You could just do:

<?php if( get_post_type_archive_link( 'cpt' ) ) : ?>
<a href="<?php echo get_post_type_archive_link( 'cpt' ); ?>">My Special Archive Link</a>
<?php endif; ?>

#2 @swissspidy
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Closing as per my last comment.

Note: See TracTickets for help on using tickets.