WordPress使用wpdb获取附件URL

时间:2019-07-01 12:23:18

标签: mysql wordpress

如何修改此查询以获取指向我的自定义帖子类型的attachment url链接。

我已经尝试了几种来自网络的解决方案,但是都没有给出预期的结果。

    $results = $wpdb->get_results(
        "SELECT ID, post_title, {$wpdb->prefix}terms.name, GROUP_CONCAT(meta_value SEPARATOR ', ') AS pictoInfos
                FROM {$wpdb->prefix}posts
                INNER JOIN {$wpdb->prefix}term_relationships
                ON ID = {$wpdb->prefix}term_relationships.object_id
                INNER JOIN {$wpdb->prefix}terms
                ON {$wpdb->prefix}term_relationships.term_taxonomy_id = {$wpdb->prefix}terms.term_id
                INNER JOIN {$wpdb->prefix}postmeta
                ON ID = {$wpdb->prefix}postmeta.post_id
                WHERE (post_type = 'recette' AND post_status = 'publish')
                AND (term_taxonomy_id = {$_GET['data']['id']} AND meta_key IN ( 'kilocalorie', 'difficulte', 'nombre_de_minutes' ) )
                GROUP BY ID ORDER BY ID DESC ",
        ARRAY_A );

0 个答案:

没有答案