admin管理员组文章数量:1279117
I have this PHP code:
$posts = get_posts([
'post_type' => 'clen',
'post_status' => 'publish',
'numberposts' => -1,
'orderby' => 'funkcia',
'order' => 'DESC'
]);
However, this code does not sort the posts by funkcia
field at all.
What is wrong with my code, please?
Thank you
I have this PHP code:
$posts = get_posts([
'post_type' => 'clen',
'post_status' => 'publish',
'numberposts' => -1,
'orderby' => 'funkcia',
'order' => 'DESC'
]);
However, this code does not sort the posts by funkcia
field at all.
What is wrong with my code, please?
Thank you
Share Improve this question asked Sep 28, 2021 at 10:09 neisorneisor 1111 bronze badge1 Answer
Reset to default 1I fixed it with the following code:
$posts = get_posts([
'post_type' => 'clen',
'post_status' => 'publish',
'numberposts' => -1,
'meta_key' => 'funkcia',
'orderby' => 'meta_value',
'order' => 'ASC'
]);
This snippet orders the gotten posts by field funkcia
.
本文标签: Order custom post type by custom field (created by PODS) via PHP
版权声明:本文标题:Order custom post type by custom field (created by PODS) via PHP 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741297593a2370906.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论