dor2p0520 2014-01-26 08:19
浏览 7
已采纳

按元数据发布ID

Hellow guys i have seen a php code which is realted to post id metadata in wordpress.

The code is

global $wpdb;

$results = $wpdb->get_results( "select post_id, meta_key from $wpdb->postmeta where meta_value = 'this is my example value.'", ARRAY_A );

I just need to know from where $wpdb->postmeta came from ?..is it applicable to use like this . how the meta_key and post_id is retrieved from$wpdb->postmeta ..i havnt seen a variable declaired like $postmeta .

Any help would be appreciated

  • 写回答

1条回答 默认 最新

  • dpiuqwwyu187975836 2014-01-26 08:31
    关注

    $Wpdb->postmeta is a constant which is holding the name of the postmeta table of wordpress sql. It's "wp_postmeta" by default. (If you chosen the "wp" db prefix.)

    WP_Postmeta DB contains the following rows:

    meta_id
    post_id
    meta_key
    meta_value
    

    You are searching in that query by "meta_value". The query will give back all rows meta_id and post_id where the meta value is equal to "this is my example value".

    Wordpress stores attributes to posts, this is what "wp_postmeta" is. So it needs to store which post does it belong to.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用