WordPress.org

Ready to get started?Download WordPress

Forums

Sql query to search all authors for a meta valuex (1 post)

  1. Nikolas
    Member
    Posted 4 years ago #

    Hello tehre. i need your help on this.

    I created a new meta_key with the name "support". I want to list all authors that have value 1 into the "support" meta_key.
    Addionaly is there any possibility to create a new different field inside MySQL, containing the ID's of the authors with meta_value =1 , instead of just listing them ?

    I have this as a sample

    <?php
    
     $querystr = "
        SELECT wposts.*
        FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
        WHERE wposts.ID = wpostmeta.post_id
        AND wpostmeta.meta_key = 'tag'
        AND wpostmeta.meta_value = 'email'
        AND wposts.post_status = 'publish'
        AND wposts.post_type = 'post'
        AND wposts.post_date < NOW()
        ORDER BY wposts.post_date DESC
     ";
    
     $pageposts = $wpdb->get_results($querystr, OBJECT);
    
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.