| | 734 | * Display or retrieve description for a post type archive. |
| | 735 | * |
| | 736 | * This is optimized for archive.php and archive-{$post_type}.php template files |
| | 737 | * for displaying the description of the post type. |
| | 738 | * |
| | 739 | * @since 3.9.0 |
| | 740 | * |
| | 741 | * @param bool $display Optional, default is true. Whether to display or retrieve description. |
| | 742 | * @return string|null Description when retrieving, null when displaying or failure. |
| | 743 | */ |
| | 744 | function post_type_archive_description( $display = true ) { |
| | 745 | if ( ! is_post_type_archive() ) { |
| | 746 | return; |
| | 747 | } |
| | 748 | |
| | 749 | $post_type = get_query_var( 'post_type' ); |
| | 750 | if ( is_array( $post_type ) ) { |
| | 751 | $post_type = reset( $post_type ); |
| | 752 | } |
| | 753 | |
| | 754 | $post_type_obj = get_post_type_object( $post_type ); |
| | 755 | /** |
| | 756 | * Filter the post type archive description. |
| | 757 | * |
| | 758 | * @since 3.1.0 |
| | 759 | * |
| | 760 | * @param string $post_type_description Post type 'description' argument. |
| | 761 | * @param string $post_type Post type. |
| | 762 | */ |
| | 763 | $description = apply_filters( 'post_type_archive_description', $post_type_obj->description, $post_type ); |
| | 764 | |
| | 765 | if ( $display ) { |
| | 766 | echo $description; |
| | 767 | } else { |
| | 768 | return $description; |
| | 769 | } |
| | 770 | } |
| | 771 | |
| | 772 | /** |