| 514 | | $posts_page = ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) ) ? get_permalink( get_option( 'page_for_posts' ) ) : home_url( '/' ); |
| | 514 | |
| | 515 | /* |
| | 516 | * If the taxonomy is exclusive to one post type (not posts/pages) *and* an archive for that post type exists, |
| | 517 | * link to the post type archive instead of home |
| | 518 | */ |
| | 519 | $taxonomy_object = get_taxonomy( $r['taxonomy'] ); |
| | 520 | $link_to_post_type_archive = false; |
| | 521 | if ( 1 === count( $taxonomy_object->object_type ) && ! in_array( $taxonomy_object->object_type['0'], array( 'post', 'page' ) ) ) { |
| | 522 | $tax_post_type = get_post_type_object( $taxonomy_object->object_type['0'] ); |
| | 523 | $link_to_post_type_archive = (bool) $tax_post_type->has_archive; |
| | 524 | } |
| | 525 | |
| | 526 | if ( $link_to_post_type_archive ) { |
| | 527 | $posts_page = get_post_type_archive_link( $taxonomy_object->object_type['0'] ); |
| | 528 | } elseif ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) ) { |
| | 529 | $posts_page = get_permalink( get_option( 'page_for_posts' ) ); |
| | 530 | } else { |
| | 531 | $posts_page = home_url( '/' ); |
| | 532 | } |