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
1140           $show_on_front = get_option( 'show_on_front' );
1141           $page_for_posts  = get_option( 'page_for_posts' );
1142
1143           if ( 'page' == $show_on_front && $page_for_posts ) {
1144                $link = get_permalink( $page_for_posts );
1145           } else {
1146                $link = get_home_url();
1147           }
1148           /** This filter is documented in wp-includes/link-template.php */
1149           return apply_filters( 'post_type_archive_link', $link, $post_type );
1150      }
1151
1152      if ( ! $post_type_obj->has_archive )
1153           return false;
1154
1155      if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) ) {
1156           $struct = ( true === $post_type_obj->has_archive ) ? $post_type_obj->rewrite['slug'] : $post_type_obj->has_archive;
1157           if ( $post_type_obj->rewrite['with_front'] )
1158                $struct = $wp_rewrite->front . $struct;
 
Line Code
1165
1166      /**
1167       * Filters the post type archive permalink.
1168       *
1169       * @since 3.1.0
1170       *
1171       * @param string $link      The post type archive permalink.
1172       * @param string $post_type Post type name.
1173       */
1174      return apply_filters( 'post_type_archive_link', $link, $post_type );
1175 }
1176
1177 /**
1178  * Retrieves the permalink for a post type archive feed.
1179  *
1180  * @since 3.1.0
1181  *
1182  * @param string $post_type Post type
1183  * @param string $feed      Optional. Feed type. Default empty.