admin管理员组

文章数量:1302292

I'd love to place the category description just after the main title in a span, like a subtitle.

add_filter ('woocommerce_page_title', function ($title) {
    // what should be here?

    $title .= "<span class='subtitle'>{$description}</span>";
    return $title;
});

Thanks.

I'd love to place the category description just after the main title in a span, like a subtitle.

add_filter ('woocommerce_page_title', function ($title) {
    // what should be here?

    $title .= "<span class='subtitle'>{$description}</span>";
    return $title;
});

Thanks.

Share Improve this question asked Oct 4, 2013 at 13:02 mircobabinimircobabini 1541 gold badge1 silver badge9 bronze badges 1
  • Please follow up on the questions you asked, it's an important part of the process on WPSE - see What should I do when someone answers my question? and Why is voting important? for a deeper insight. Thank you! – Nicolai Grossherr Commented Nov 7, 2013 at 12:52
Add a comment  | 

2 Answers 2

Reset to default 2

There is an extra hook you can use for this woocommerce_archive_description, hook into it like this:

    add_action( 'woocommerce_archive_description', 'wc_category_description' );
    function wc_category_description() {
        if ( is_product_category() ) {
            global $wp_query;
            $cat_id = $wp_query->get_queried_object_id();
            $cat_desc = term_description( $cat_id, 'product_cat' );
            $subtit = '<span class="subtitle">'.$cat_desc.'</span>';
            echo $subtit;
        }
    }

Try this in your archive-product.php template:

<span class="subtitle">
    <?php do_action( 'woocommerce_archive_description' ); ?>
</span>

本文标签: pluginsWoocommerce category description as subtitle