私はwoocommerceのためにBoosterというプラグインを使用します。私は自分の製品フィードを構築するためにそれを使用しています。woocommerce boosterプラグインのショートコードを編集する
「フルーツ、りんご、青りんご」
は、残念ながら私はこの形式でこれらのカテゴリを返すためにそれを必要とする:この形式での製品カテゴリのブランチ全体を返すショート(文字列)があります:
"フルーツ|りんご|青りんご"
私はプラグイン・ファイルで、このショートする機能を見つけました:ショートコードから
function wcj_product_categories($atts) {
$return = (WCJ_IS_WC_VERSION_BELOW_3) ? $this->the_product->get_categories() : wc_get_product_category_list($atts['product_id']);
return (false === $return) ? '' : $return;
}
そして "wc_get_product_category_list" 機能は、次のようになります。|
function wc_get_product_category_list($product_id, $sep = ', ', $before = '', $after = '') {
return get_the_term_list($product_id, 'product_cat', $before, $sep, $after);
}
私は "のために "" 置き換えることができます"このwoocommerce関数では直接、しかし、私はそれが他のプラグインやwoocommerce関数で問題を引き起こす恐れがあるので、" wc_get_product_category_list "を介してカテゴリリスト(文字列)を取得するように基本的にプラグイン関数を編集し、 /私はPHPでこれを行うにはどのようには考えている私の下手な英語のため申し訳ありません
、あなたはポイントを得る願って助けを おかげ
|変数にと「」用の変更 『』。。。 /編集:このようにすることは可能ですか?
function wcj_product_categories($atts) {
$product_list = wc_get_product_category_list($atts['product_id']);
$new_string = str_replace(","," |",$product_list);
$return = (WCJ_IS_WC_VERSION_BELOW_3) ? $this->the_product->get_categories() : $new_string;
return (false === $return) ? '' : $return;
}