私のテーマには、たくさんの機能を持つfunction-template.phpファイルがあります。それらの1つは、サイトのカテゴリの説明をエコーします。テーマのオーバーライド
function woocommerce_taxonomy_archive_description() {
if (is_tax(array('product_cat', 'product_tag')) && get_query_var('paged') == 0) {
global $wp_query;
$cat = $wp_query->get_queried_object();
$thumbnail_id = get_woocommerce_term_meta($cat->term_id, 'thumbnail_id', true);
$image = wp_get_attachment_image_src($thumbnail_id, 'full');
$description = apply_filters('the_content', term_description());
if ($image && yit_get_option('shop-category-image') == 1) {
echo '<div class="term-header-image"><img src="' . $image[0] . '" width="' . $image[1] . '" height="' . $image[1] . '" alt="' . $cat->name . '" /></div>';
}
if ($description) {
echo '<div class="term-description">' . $description . '</div>';
}
}
}
代わりに別の変数をエコーする必要があります。既存の関数を "上書き"する方法はありますか?
私はmu-pluginsなどでちょっとしたことをしてきましたが、成功しませんでした。 カスタム関数ファイルに同じ関数を追加すると、常にFatal error: Cannot redeclare woocommerce_taxonomy_archive_description() (previously declared in
エラーが発生します。
子どものテーマと呼ばれるもの – maxpovver