wpdb getting avatars and author url

You just need to return the user ID in the main select and use that as the author ID. Also I probably confused the issue previously by using echo with commas (separate arguments) rather than dots (one concatenated argument). $weekly = $wpdb->get_results ( ” SELECT u.ID, ( SELECT CONCAT_WS(‘.’, SUM(CASE WHEN p.post_date > ‘$date2’ THEN … Read more

Using $wpdb in a plugin, what sort of data does it return?

Check out the codex on wpdb. In your case, get_row returns the first row of the result set as an object. There’s no need for any mysqli_* functions when using $wpdb. if ( $result2 ) echo json_encode( $result2 ); And a heads up for SQL injection – use the prepare method: $wpdb->get_row( $wpdb->prepare( “SELECT * … Read more

Ascending order of yearly archives [closed]

You will have to define post order in second SQL query too. Try this one. // get years that have posts $years = $wpdb->get_results( “SELECT YEAR(post_date) AS year FROM wp_posts WHERE post_type=”post” AND post_status=”publish” GROUP BY year DESC” ); foreach ( $years as $year ) { // get posts for each year $posts_this_year = $wpdb->get_results( … Read more

Outputting query results

By default, wordpress get_results return a numerically array of objects, so to use echo to print your data yo should do something like; foreach($myrows as $line){ echo $line->question; }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)