- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试查询 Wordpress 帖子。
我创建了一个自定义帖子类型 People
。每个 people
帖子都有自定义字段 name
、age
、location
、birthday
等.自定义字段是使用高级自定义字段插件创建的。
我想查询 People
自定义帖子类型的所有自定义字段。
我想要这样的输出:
+----+-------------+-----------+--------+-----------------------------+----------+-----+
| id | post_title | name | age | location | birthday |
+----+-------------+-----------+--------+-----------------------------+----------+-----+
| 1 | SAMPLE | some_name | XX | sample_location | 10/07/1980 |
| 1 | SAMPLE | some_name | XX | sample_location | 10/07/1980 |
| 1 | SAMPLE | some_name | XX | sample_location | 10/07/1980 |
| 1 | SAMPLE | some_name | XX | sample_location | 10/07/1980 |
| 1 | SAMPLE | some_name | XX | sample_location | 10/07/1980 |
+----+-------------+-----------+--------+-----------------------------+----------+-----+
执行此操作的正确语法是什么?
我试过:
SELECT *
FROM `wp_posts` , `wp_postmeta`
WHERE `post_type` = 'people'
但这列出了所有 wordpress 常规帖子字段。
有人可以帮忙吗?
最佳答案
这里是任何人可能有同样问题的解决方案!
SELECT posts_people.ID AS people_ID,
posts_people.post_title AS people_post_title,
(select meta_value from wp_postmeta where meta_key = 'name' AND post_id = posts_people.ID) as name,
(select meta_value from wp_postmeta where meta_key = 'age' AND post_id = posts_people.ID) as age,
(select post_title from wp_posts where ID = SUBSTRING_INDEX(SUBSTRING_INDEX((select meta_value from wp_postmeta where meta_key = 'location' AND post_id = posts_people.ID),'";',1),':"',-1)) as location,
(select meta_value from wp_postmeta where meta_key = 'birthday' AND post_id = posts_people.ID) as stelexos_kinito
FROM wp_posts AS posts_people
WHERE post_type = 'people' and post_status = 'publish'
关于php - 自定义帖子类型的Mysql SELECT自定义字段(post_meta),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54056789/
我正在尝试查询 Wordpress 帖子。 我创建了一个自定义帖子类型 People。每个 people 帖子都有自定义字段 name、age、location、birthday 等.自定义字段是使用
如何限制此代码中的字符数? .get_post_meta($post->ID,'smple1',true). 我试过以下方法: $trim_length = 21; //desired length
我将查询限制为使用 6 个月前的显示帖子,效果很好。 但我需要它基于 post_meta 表中的日期而不是“post_date_gmt”。 在我的例子中,我有一个名为 payment_date 的 m
我使用以下代码来选择具有以下 post_meta 键的产品:_product_new、_product_almost_new 和 _product_old。 我的代码: add_action( 'wo
function yummy_sounds_custom(){ add_menu_page( __( 'Custom Menu Title', 'textdomain' ),
我正在使用 Wordpress 并尝试创建一个 View ,以便更轻松地查看和分析我的度假村数据。度假村数据存储在 Wordpress 的 post_meta 表中,并在称为“度假村”的自定义帖子类型
我想对 WordPress 站点(wp_postmeta 表)中的帖子元数据执行一些更新。已知的 good'ol 函数 update_post_meta() 正在完成这项工作,并且还将检查,如果 ke
我知道这是不对的,尽管这是可行的。 我需要找到给定半径和位置附近的所有帖子(作为收入),但我需要子查询 post_meta 中的经纬度信息。 它会伤害你的眼睛,所以在这里: /* lat -23.64
我正在处理亚马逊附属 wordpress 页面。为此,我使用 aws_signed_request 函数从亚马逊获取价格和链接。 这是返回 xml 的 aws_signed_request 函数:
我正在建立一个汽车服务数据库。每个汽车服务都可以维修多种型号的汽车。 存储汽车服务和类型之间的关系以便以后能够查询的最佳方式是什么? 我的选择是: 对于每辆车,将模型保存为 post_meta 作为单
我在 WooCommerce 中有 5000 多种产品,我正在寻找 SQL 查询来根据其 SKU 设置条形码。 “条形码”和“sku”都是自定义帖子元。基本上,类似于: UPDATE wp_postm
尝试在 WordPress 环境中根据当前选择的父 ID 递归选择数据库字段。 在 WordPress 方面: 我正在执行一个 pre_get_posts 过滤器以仅检索与用户元相关联的帖子。这很简单
我找到了几个关于如何“插入……”“不存在的地方”的解释,但这并没有解决我的问题。 我正在使用 Wordpress,我有一个名为 wp_posts 的表,其中包含帖子、产品、product_variat
我是一名优秀的程序员,十分优秀!