Danh mục, thẻ và các trang lưu trữ phân loại của CPT chỉ hiển thị văn bản giới thiệu. Đoạn mã sau sẽ hiển thị mô tả phân loại WordPress mặc định khi bạn không sử dụng văn bản giới thiệu. Nếu bạn có cả hai (Văn bản mô tả và văn bản giới thiệu) thì văn bản giới thiệu sẽ hiển thị.
Kiểm tra ý kiến này.
/** * Filename: taxonomy_title_description.php * * @author Chinmoy Paul * @link http://genesisdeveloper.me * @copyright Copyright (c) 2015 Genesis Developer. */ //* Add this code in your functions.php file remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 ); add_action( 'genesis_before_loop', 'gd_do_taxonomy_title_description', 14 ); /** * Add title and description to category / tag / taxonomy archive pages. * If the page is not a category, tag or taxonomy term archive, or there's no term, or * no term meta set, then nothing extra is displayed. * * If there have no intro text then default category description will appear * * @return null Return early if not the correct archive page, not page one, or no term meta is set. */ function gd_do_taxonomy_title_description() { global $wp_query; if ( ! is_category() && ! is_tag() && ! is_tax() ) return; $term = is_tax() ? get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ) : $wp_query->get_queried_object(); if ( ! $term || ! isset( $term->meta ) ) return; $headline = $intro_text = ''; if ( $term->meta['headline'] ) { $headline = sprintf( '<h1 %s>%s</h1>', genesis_attr( 'archive-title' ), strip_tags( $term->meta['headline'] ) ); } else { if ( genesis_a11y( 'headings' ) ) { $headline = sprintf( '<h1 %s>%s</h1>', genesis_attr( 'archive-title' ), strip_tags( $term->name ) ); } } $desc = category_description( $term->term_id ); if ( ! empty ( $desc ) ) $intro_text = apply_filters( 'genesis_term_intro_text_output', $desc ); if( $term->meta['intro_text'] ) $intro_text = apply_filters( 'genesis_term_intro_text_output', $term->meta['intro_text'] ); if ( $headline || $intro_text ) printf( '<div %s>%s</div>', genesis_attr( 'taxonomy-archive-description' ), $headline . $intro_text ); }