Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: post_type_archive_link

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
1299           $show_on_front  = get_option( 'show_on_front' );
1300           $page_for_posts = get_option( 'page_for_posts' );
1301
1302           if ( 'page' === $show_on_front && $page_for_posts ) {
1303                $link = get_permalink( $page_for_posts );
1304           } else {
1305                $link = get_home_url();
1306           }
1307           /** This filter is documented in wp-includes/link-template.php */
1308           return apply_filters( 'post_type_archive_link', $link, $post_type );
1309      }
1310
1311      if ( ! $post_type_obj->has_archive ) {
1312           return false;
1313      }
1314
1315      if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) ) {
1316           $struct = ( true === $post_type_obj->has_archive ) ? $post_type_obj->rewrite['slug'] : $post_type_obj->has_archive;
1317           if ( $post_type_obj->rewrite['with_front'] ) {
 
Line Code
1326
1327      /**
1328       * Filters the post type archive permalink.
1329       *
1330       * @since 3.1.0
1331       *
1332       * @param string $link      The post type archive permalink.
1333       * @param string $post_type Post type name.
1334       */
1335      return apply_filters( 'post_type_archive_link', $link, $post_type );
1336 }
1337
1338 /**
1339  * Retrieves the permalink for a post type archive feed.
1340  *
1341  * @since 3.1.0
1342  *
1343  * @param string $post_type Post type.
1344  * @param string $feed      Optional. Feed type. Possible values include 'rss2', 'atom'.