$_GET["s"], "order" => "ASC", -6ren">
gpt4 book ai didi

php - WordPress 按自定义字段排序,按自定义字段对列表进行排序

转载 作者:行者123 更新时间:2023-11-29 19:16:11 25 4
gpt4 key购买 nike

我使用此代码来显示按“postnr”排序的列表,postnr 是自定义字段。

$config = [
"s" => $_GET["s"],
"order" => "ASC",
"orderby" => "postnr"
];

如何对 WordPress 中的自定义字段“postnr”进行排序 orderby

最佳答案

您必须使用 'orderby' => 'meta_value' 并将 meta_key 定义为 'meta_key' => 'postnr', .

这是代码:

$config = [
"s" => $_GET["s"],
"order" => "ASC",
'meta_key' => 'postnr',
'orderby' => 'meta_value' //or 'meta_value_num'
];

引用::Order & Orderby Parameters

希望这有帮助!

关于php - WordPress 按自定义字段排序,按自定义字段对列表进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42688673/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com