Displaying and Querying Posts with Featured image

Start by cleaning up your code; $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 3, ‘order’ => ‘asc’ ); $home_shows = new WP_Query($args); //setup your loop here if( $home_shows->have_posts() ): while( $home_shows->have_posts() ): $home_shows->the_post(); //fetch featured image if exists if ( has_post_thumbnail() ) { the_post_thumbnail(array(486,226)); } //fetch content the_content(); //etc… endwhile; endif; What output do … Read more

WordPress Query based on random taxonomy

<?php $all_books = get_terms( ‘history_books’ ); // Get all history book terms. $rand_book = $all_books[ array_rand( $all_books ) ]; // Select one at random. $related = get_posts( array( ‘posts_per_page’ => 5, ‘tax_query’ => array( array( ‘taxonomy’ => ‘history_books’, ‘terms’ => array( $rand_book->term_id ), ) ) ) ); ?> <h3> <a href=”https://wordpress.stackexchange.com/questions/104280/<?php echo get_term_link( $rand_book ) … Read more

how to get the top 10 popular blogs

If I understand you correctly, something like this should help you. global $wpdb; $results = $wpdb->get_results( “SELECT post_author, SUM(comment_count) as comments FROM {$wpdb->posts} WHERE post_type=”post” AND post_status=”publish” GROUP BY post_author ORDER BY comments DESC LIMIT 10″); This will return you 10 authors of most commented posts (with highest sum of comments count of each post … Read more

Multiple instances of query_posts

If you have 8 categories, you need 8 queries. To improve your code use WP_Query instead of query_posts: <?php $categories = get_categories(); if ( ! empty($categories) ) { ?> <ul class=”tabs”> <?php foreach ($categories as $c ) { ?> <li> <a href=”#tab<?php echo $c->term_id; ?>”> <img src=”<?php bloginfo(‘template_directory’); ?>/images/logo-<?php echo $c->slug; ?>.png” alt=”<?php echo $c->name; … Read more

How to get posts ordered by using their categories?

Before answer I want to say that your code is not really wrong but can be improved: why run 2 queries when you can run only one? caller_get_posts is deprecated, use ignore_sticky_posts, instead get_terms has not title_li nor show_count argument. Moreover $taxonomy is the first argument and do nothing in the $args array (second argument). … Read more

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