如何在wordpress插件开发中手动发布缩略图URL?

时间:2014-07-05 12:03:38

标签: php mysql wordpress wordpress-plugin

我希望手动发布缩略图网址而不使用此代码

wp_get_attachment_url( get_post_thumbnail_id($post->ID) );

例如使用MySQL查询。可能吗?

1 个答案:

答案 0 :(得分:0)

尝试此MySql查询

 SELECT
        p1.*,
        wm2.meta_value
    FROM 
        wp_posts p1
    LEFT JOIN 
        wp_postmeta wm1
        ON (
            wm1.post_id = p1.id 
            AND wm1.meta_value IS NOT NULL
            AND wm1.meta_key = "_thumbnail_id"              
        )
    LEFT JOIN 
        wp_postmeta wm2
        ON (
            wm1.meta_value = wm2.post_id
            AND wm2.meta_key = "_wp_attached_file"
            AND wm2.meta_value IS NOT NULL  
        )
    WHERE
        p1.post_status="publish" 
        AND p1.post_type="post"
    ORDER BY 
        p1.post_date DESC