【发布时间】:2020-10-02 20:50:59
【问题描述】:
我有一个存档页面,其中显示与作者相关的产品。但是我使用的小部件只允许我选择“当前查询”,并且只向我显示作者产品的完整列表,而无法编辑更多功能。
我有兴趣编辑要显示的产品数量并能够按特色产品进行过滤。
我看到它允许我从 ID 链接自定义查询过滤器,但我不明白如何构建代码以使其工作。我会给你一个例子来说明代码是如何的,但这种情况是帖子的。
// Showing multiple post types in Posts Widget
add_action( 'elementor/query/my_custom_filter', function( $query ) {
// Here we set the query to fetch posts with
// post type of 'custom-post-type1' and 'custom-post-type2'
$query->set( 'post_type', [ 'custom-post-type1', 'custom-post-type2' ] );
} );
【问题讨论】:
标签: php wordpress woocommerce product elementor