25% off ProSNIPC25OFF

Display Archive and Term Description on Archives

Outputs the term or author description block above the post list on archive pages.

PHPby SnipCraft
php
<?php
add_action( 'loop_start', 'scseed_render_archive_description' );
function scseed_render_archive_description( $query ) {
    if ( ! $query->is_main_query() || is_admin() ) {
        return;
    }
    if ( ! is_archive() && ! is_category() && ! is_tag() && ! is_tax() && ! is_author() ) {
        return;
    }
    static $scseed_desc_done = false;
    if ( $scseed_desc_done ) {
        return;
    }
    $scseed_desc_done = true;

    $description = get_the_archive_description();
    if ( empty( $description ) ) {
        return;
    }
    echo '<div class="scseed-archive-desc" style="margin-bottom:1.5em;padding:1em;background:#f9f9f9;border-left:3px solid #ccc;">'
        . wp_kses_post( $description )
        . '</div>';
}
#archive#category#description#display#taxonomy