admin管理员组文章数量:1125919
I have a website that lists paintings. All these paintings are made by various artists. I've added a custom post type "paintings" and created a form so each painting can be easily entered. What I want is a way to sort these paintings by artist. I can't figure out the correct way to do this.
What I have done now is created the following query;
add_action( 'elementor/query/kunst_op_kunstenaar', function( $query ) {
$query->set( 'meta_key', 'kunstenaar_tekst');
$query->set( 'orderby', array(
'meta_value_num' => 'ASC',
'date' => 'ASC'
));
And that works, sort of, when adding a new artist this will get a new ID of course and will sort them on the last page, since the ID is the highest.
How can I create a query that will sort the artists the right way?
I have a website that lists paintings. All these paintings are made by various artists. I've added a custom post type "paintings" and created a form so each painting can be easily entered. What I want is a way to sort these paintings by artist. I can't figure out the correct way to do this.
What I have done now is created the following query;
add_action( 'elementor/query/kunst_op_kunstenaar', function( $query ) {
$query->set( 'meta_key', 'kunstenaar_tekst');
$query->set( 'orderby', array(
'meta_value_num' => 'ASC',
'date' => 'ASC'
));
And that works, sort of, when adding a new artist this will get a new ID of course and will sort them on the last page, since the ID is the highest.
How can I create a query that will sort the artists the right way?
Share Improve this question asked Feb 6, 2024 at 16:25 SystemedicSystemedic 11 Answer
Reset to default 0I don't know much about elementor, but to keep this as a Purely WordPress answer you need to change your query to sort by post name. The code you provided looks like a pre-query filter so you should try this:
add_action( 'elementor/query/kunst_op_kunstenaar', function( $query ) {
$query->set( 'order', 'ASC');
$query->set( 'orderby', 'title');
}
This sets your order by function to sort by title and then order to ascending (a-z).
本文标签: queryElementorSort by name
版权声明:本文标题:query - Elementor - Sort by name 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736661335a1946432.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论