Formatting a date/time returned from a custom $wpdb query

A much simpler method to bypass these issues is using WP_Query: $popularQuery = array(‘orderby’ => ‘comment_count’, ‘posts_per_page’ => ‘-1’, ‘author’ => 1); $popularPosts = new WP_Query($popularQuery); while($popularPosts->have_posts()) : $popularPosts->the_post(); ?> <tr> <td><a href=”https://wordpress.stackexchange.com/questions/23820/<?php the_permalink(); ?>”><?php the_title(); ?></a></td> <td><?php the_author(); ?></td> <td><?php the_time(‘j M Y h:i A’) ?></td> <td><?php comments_number(); ?></td> </tr> <?php endwhile; Also note … Read more

How can I change my meta_query to SQL wpdb query?

Several things, Firstly you can add the following for pagination: ‘paged’ => ( get_query_var(‘paged’) ? get_query_var(‘paged’) : 1 ) This removes the need for the array_merge. Otherwise your existing code is fine except for some indentation. I would add the rest of the query though, e.g. defining the post type, the posts per page, etc

$wpdb->get_var next var?

Instead of querying the database directly you could use the following code instead. printf( ‘<p>Total views : %s</p>’, get_post_meta( get_the_ID(), ‘views’, true ) );

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