Support » Fixing WordPress » Pass current author ID into a SQL Query

  • Hello there.
    Is there a way to pass the current author ID, dynamically into a query?
    I will use this to display some fields from MySQL for the current author.

Viewing 1 replies (of 1 total)
  • This is UNTESTED, but should give you a starting point:

    <?php
        // Use this within The Loop
        $author = get_the_author_meta('ID');
        $sql = "SELECT * FROM $wpdb->users WHERE ID = '$author' ";
        $myquery = new WP_Query();
        $results = $myquery->get_results($sql);
    
       // Do stuff with $results
    ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Pass current author ID into a SQL Query’ is closed to new replies.