admin 管理员组文章数量: 1086019
In the archive page, I would like to show in a loop grid widget ONLY the posts that belong either to the displayed archive category and also to a specific category which slug is "special-one", meaning that they have to be from both categories (operator AND). So I have set up an archive page template in Elementor theme builder. Just in that single loop and not as default for the archive page.
I Used the following code:
add_action( 'elementor/query/special_archive_filter', function( query )
if ( is_category() )
$category_id = get_queried_object_id();
$special_category_id = special-one;
$categorie query->set( 'tax_query', array(
array(
'taxonomy' => 'category',
'field' => 'id',
'terms' => array( category_id,special_category_id ),
'operator' => 'AND',
),
));
}
});
But this code is not giving me the expected result. What I am doing wrong?
本文标签: phpAdd a specific category in Elementor Category Archive Template page for a WidgetStack Overflow
版权声明:本文标题:php - Add a specific category in Elementor Category Archive Template page for a Widget - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744076226a2529402.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论