[wp-trac] [WordPress Trac] #34428: New function `has_archive_post_type()`

WordPress Trac noreply at wordpress.org
Sat Oct 24 08:52:33 UTC 2015


#34428: New function `has_archive_post_type()`
-------------------------------+------------------------------
 Reporter:  sebastian.pisula   |       Owner:
     Type:  enhancement        |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Posts, Post Types  |     Version:
 Severity:  normal             |  Resolution:
 Keywords:                     |     Focuses:
-------------------------------+------------------------------

Comment (by swissspidy):

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

 {{{#!php
 <?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; ?>
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34428#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list