php - Wordpress如何按订单输入值排序
问题描述
当您在 Wordpress 中创建帖子时,有一个名为“订单”的字段。
我怎样才能使它工作,例如,我把5
帖子5th
放在页面上显示的位置?
我试过这个但没有奏效:
<?php
$args = array(
'post_type' => 'team',
'posts_per_page' => 30,
'orderby' => 'meta_value_num',
'order' => 'ASC'
);
$the_query = new WP_Query($args);
if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post();
?>
解决方案
如果“订单”是一个自定义字段,那么您可以执行以下操作:
$the_query = new WP_Query(array(
'post_type' => 'team',
'posts_per_page' => 30,
'meta_key' => 'order',
'orderby' => 'meta_value',
'order' => 'ASC',
));
请让我知道这对你有没有用!
推荐阅读
- c# - 如何在 C# 中修复此 StoredProcedure 的空值?
- javascript - React - 在 DOM 渲染时加载屏幕?
- python - 在 while 循环内无法定期识别输入
- php - Mailgun api 响应以验证邮件
- marklogic - MarkLogic - mlcp 作业未向调度程序返回成功消息
- pandas - zscore vs minmax 归一化,为什么它们的结果看起来一样
- python - 在基于类的视图中覆盖 GET 请求时如何引用表单?
- ios - 如何防止内容在 iPhone X 等缺口手机的工具栏上方可见?
- django - 可以使用 Django 为小型内部 Web 应用程序提供静态文件吗?
- python - 父类方法调用父类方法,而不是子类方法