Where is the post featured image link stored in the WordPress database?

前端 未结 4 444
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-30 06:06

Where is the featured image link stored in the WordPress Database? I searched in the wp_postmeta table but I cannot find out the exact post_id and

4条回答
  •  一生所求
    2021-01-30 07:01

    The featured image ID is stored in wp_postmeta with a meta_key called _thumbnail_id. Example:

    ╔═════════╦═════════╦═══════════════╦═══════════╗
    ║ meta_id ║ post_id ║ meta_key      ║ meta_value║
    ╠═════════╬═════════╬═══════════════╬═══════════╣
    ║ 200     ║ 4       ║ _thumbnail_id ║ 48        ║
    ╚═════════╩═════════╩═══════════════╩═══════════╝
    

    The actual thumbnail link is then contained in wp_posts with a post_type of attachment. Example:

    ╔════╦════════════╦═════════════════════════════════════════════════════╗
    ║ ID ║ post_type  ║ guid                                                ║
    ╠════╬════════════╬═════════════════════════════════════════════════════╣
    ║ 48 ║ attachment ║ http://example.com/wp-content/uploads/yourimage.png ║
    ╚════╩════════════╩═════════════════════════════════════════════════════╝
    

提交回复
热议问题