我有一些模板与元素或主题生成器。但是,在嵌套档案中显示它们的选项非常有限。这是我的案子
我有一个叫做位置的自定义分类(标签)。然后,在添加清单时进一步嵌套。它获取地址并将其细分为区域、城市和地区,然后插入设置条件。这里没有戏剧。这就是它的样子。

和
我在主题构建器中内置了以下模板。
元素只允许将模板应用到

但是,在我的例子中,我想将4个不同的模板应用到父(地区)、子(城市)、孙子(地区)和曾孙(在本地的服务)。
元素允许在主题构建器中注册自定义条件,但是,我不能。欢迎!
add_action( 'elementor/theme/register_conditions', function( $conditions_manager ) {
class Subcategory_Archive extends ElementorPro\Modules\ThemeBuilder\Conditions\Taxonomy {
private $taxonomy;
public function get_name() {
return 'child_of_' . $this->taxonomy->name;
}
public function get_label() {
return sprintf( __( 'Direct Child %s Of', 'elementor-pro' ), $this->taxonomy->labels->singular_name );
}
public function __construct( $data ) {
parent::__construct( $data );
$this->taxonomy = $data['object'];
}
public function is_term() {
$taxonomy = $this->taxonomy->name;
$current = get_queried_object();
return ( $current && isset( $current->taxonomy ) && $taxonomy === $current->taxonomy );
}
public function check( $args ) {
$id = (int) $args['id'];
/**
* @var \WP_Term $current
*/
$current = get_queried_object();
if ( ! $this->is_term() || 0 === $current->parent ) {
return false;
}
while ( $current->parent > 0 ) {
if ( $id === $current->parent ) {
return true;
}
$current = get_term_by( 'id', $current->parent, $current->taxonomy );
}
return $id === $current->parent;
}
}
$taxonomy = get_term('location');
$conditions_manager->get_condition( 'listing' )->register_sub_condition( new Subcategory_Archive([ 'object' => $taxonomy ]) );
}, 100 );我需要帮助,为档案页注册自定义条件,以显示这些分类单元。
注:有个别选择每个学期和应用模板。然而,我有超过2500种上市类别(即咖啡店)和数以千计的地方和城市。我可以管理区域,因为在新西兰只有16个地区。
元素文档:https://developers.elementor.com/docs/theme-conditions/
发布于 2023-04-19 09:35:47
你在那个问题上还有什么进展吗?我现在也面临着同样的问题
<#>更新
每个人在解决这个问题上都有困难,请看一看@ elementors问题。魔术在于检查函数。
https://wordpress.stackexchange.com/questions/411801
复制相似问题