- ステータス
- 開発者により解決済み
- 解決されたバージョン
- Unlimited Elements for Elementor 2.0.5
- 関連するプラグイン/テーマ
- Unlimited Elements for Elementor
- トピックタグ
- Compatibility, Elementor Custom Widgets
問題の概要
WPMLおよびYoast SEOとともにUnlimited Elements for ElementorのPosts List Elementを使用する場合、翻訳ではモジュールがYoastのプライマリーカテゴリーを表示しません。代わりに、投稿が属する最初のカテゴリー(アルファベット順)が表示されます。
回避策
続行する前に、必ずサイトの完全なバックアップを作成してください。
- …/wp-content/plugins/unlimited-elements-for-elementor/provider/provider_params_processor.class.phpファイルを開きます。
- 574行目の
getPostMainCategory関数を探します。 - 以下を:
/** * get post main category from the list of terms */ private function getPostMainCategory($arrTerms, $postID){ //get term data if(count($arrTerms) == 1){ //single $arrTermData = UniteFunctionsUC::getArrFirstValue($arrTerms); return($arrTermData); } $arrMeta = UniteFunctionsWPUC::getPostMeta($postID,true); $mainCategoryID = UniteFunctionsUC::getVal($arrMeta, "_yoast_wpseo_primary_category"); if(empty($mainCategoryID)) $mainCategoryID = UniteFunctionsUC::getVal($arrMeta, "rank_math_primary_category"); if(empty($mainCategoryID)){ unset($arrTerms["uncategorized"]); $arrTermData = UniteFunctionsUC::getArrFirstValue($arrTerms); return($arrTermData); }
- 次のように置き換えます:
/** * get post main category from the list of terms */ private function getPostMainCategory($arrTerms, $postID){ //get term data if(count($arrTerms) == 1){ //single $arrTermData = UniteFunctionsUC::getArrFirstValue($arrTerms); return($arrTermData); } $arrMeta = UniteFunctionsWPUC::getPostMeta($postID,true); $mainCategoryID = UniteFunctionsUC::getVal($arrMeta, "_yoast_wpseo_primary_category"); if(empty($mainCategoryID)) $mainCategoryID = UniteFunctionsUC::getVal($arrMeta, "rank_math_primary_category"); // WPML Workaround for compsupp-8023 if (!empty($mainCategoryID)) { $mainCategoryID = apply_filters('wpml_object_id', $mainCategoryID, 'category', true); } if(empty($mainCategoryID)){ unset($arrTerms["uncategorized"]); $arrTermData = UniteFunctionsUC::getArrFirstValue($arrTerms); return($arrTermData); }