php - 从 WP_Meta_query 返回帖子 ID
问题描述
运行此代码后,我希望获取 post_id 列:
$query_args = array (
array(
'key' => 'registration',
'value' => $reg,
'compare' => '='
)
);
$query = new WP_Meta_Query($query_args);
请问如何检索帖子的post_id?
解决方案
您可以像这样使用get_the_ID():
$post_id = get_the_ID();
推荐阅读
- ruby-on-rails - 在保存模型之前 Sidekiq 邮件程序作业访问数据库
- node.js - 一台服务器上的 React 和 GraphQL
- jupyter-notebook - Kubeflow:笔记本服务器卡在加载中
- python-3.x - Python:查找排序和旋转数组中的最小元素
- c# - 如何在字符串中找到单词的所有起始索引?
- javascript - 禁用街景,全屏谷歌地图反应
- flutter - 如何使用文本字段过滤我的 StreamBuilder 列表?
- php - 关闭引导卡(永久)
- javascript - 如何将 ajax 与数据表一起使用,django
- node.js - 如何获取嵌入图像的原始网址?不和谐.js