| | 793 | * Retrieve or display the archive title based on the queried object |
| | 794 | * |
| | 795 | * @since 3.6.0 |
| | 796 | * |
| | 797 | * @param string $prefix Optional. What to display before the title. |
| | 798 | * @param string $container Optional. The HTML container to wrap the type of archive with. |
| | 799 | * @param bool $display Whether to display or return the archive title. |
| | 800 | * @return string Text archive title |
| | 801 | */ |
| | 802 | function the_archive_title( $prefix = '', $container = 'span', $display = true ) { |
| | 803 | $before = $after = ''; |
| | 804 | if ( ! empty( $container ) ) { |
| | 805 | $before = sprintf( '<%s>', $container ); |
| | 806 | $after = sprintf( '</%s>', $container ); |
| | 807 | } |
| | 808 | |
| | 809 | if ( is_day() ) { |
| | 810 | $title = sprintf( __( 'Daily Archives: %s' ), $before . get_the_date() . $after ); |
| | 811 | } elseif ( is_month() ) { |
| | 812 | $title = sprintf( __( 'Monthly Archives: %s' ), $before . get_the_date( _x( 'F Y', 'monthly archives date format' ) ) . $after ); |
| | 813 | } elseif ( is_year() ) { |
| | 814 | $title = sprintf( __( 'Yearly Archives: %s' ), $before . get_the_date( _x( 'Y', 'yearly archives date format' ) ) . $after ); |
| | 815 | } elseif ( is_tag() ) { |
| | 816 | $title = sprintf( __( 'Tag Archives: %s' ), $before . single_tag_title( '', false ) . $after ); |
| | 817 | } elseif ( is_category() ) { |
| | 818 | $title = sprintf( __( 'Category Archives: %s' ), $before . single_cat_title( '', false ) . $after ); |
| | 819 | } elseif ( is_tax() ) { |
| | 820 | $tax = get_taxonomy( get_queried_object()->taxonomy ); |
| | 821 | /* translators: 1: Taxonomy singular name, 2: Current taxonomy term */ |
| | 822 | $title = sprintf( __( '%1$s Archives: %2$s' ), $tax->labels->singular_name, $before . single_term_title( '', false ) . $after ); |
| | 823 | } elseif ( is_author() ) { |
| | 824 | $title = sprintf( __( 'Author Archives: %s' ), $before . get_the_author() . $after ); |
| | 825 | } elseif ( is_post_type_archive() ) { |
| | 826 | $title = sprintf( __( 'Archives: %s' ), $before . post_type_archive_title( '', false ) . $after ); |
| | 827 | } else { |
| | 828 | $title = __( 'Archives' ); |
| | 829 | } |
| | 830 | |
| | 831 | $title = $prefix . $title; |
| | 832 | |
| | 833 | if ( $display ) |
| | 834 | echo apply_filters( 'the_archive_title', $title ); |
| | 835 | else |
| | 836 | return apply_filters( 'the_archive_title', $title ); |
| | 837 | } |
| | 838 | |
| | 839 | /** |
| | 840 | * Retrieve or display tag, category or term description |
| | 841 | * |
| | 842 | * @since 3.6.0 |
| | 843 | * |
| | 844 | * @uses term_description() |
| | 845 | * |
| | 846 | * @param bool $display Whether to display or return the archive description. |
| | 847 | * @return string Category, tag or term description |
| | 848 | */ |
| | 849 | function the_archive_description( $display = true ) { |
| | 850 | if ( is_tag() || is_category() || is_tax() ) { |
| | 851 | $term = get_queried_object(); |
| | 852 | $taxonomy = $term->taxonomy; |
| | 853 | $description = term_description( '', $taxonomy ); |
| | 854 | } |
| | 855 | |
| | 856 | if ( $display ) |
| | 857 | echo apply_filters( 'the_archive_description', $description ); |
| | 858 | else |
| | 859 | return apply_filters( 'the_archive_description', $description ); |
| | 860 | } |
| | 861 | |
| | 862 | /** |