INSERT in table row fatal error

This is more or less a programming question. $wpdb is not available everywhere. It’s a global variable. If you want to use it inside your own functions, just add global $wpdb; at the first line of the function. For general programming questions, this might be another discovery for you: stackoverflow.com,it is about programming in specific. … Read more

How to Show Comment Count on Related Posts?

get_comments_number works in the loop. You’re using it outside. So do something like this $category = get_the_category(); $category = $category[0]; $category = $category->cat_ID; $posts = get_posts(‘numberposts=5&offset=0&orderby=post_date&order=DESC&category=’.$category); foreach($posts as $post){ setup_postdata($post); $total = get_comments_number(); echo ‘here we create the HTML and content for the post’; } wp_reset_query();

show x number of posts from y category on homepage

That sounds outside the scope of what you’re going to get from query_posts. If you have a custom template for your home page and you want to sprinkle in advertisement posts I would change the query_posts() that excludes the advertisement category, do a separate get_posts() for 2 posts in the advertisement category, and then put … Read more

WordPress Custom Query to get Most Commented Posts in the Past 7 Days

This should do it: $querystr = “SELECT comment_count, ID, post_title FROM $wpdb->posts wposts, $wpdb->comments wcomments WHERE wposts.ID = wcomments.comment_post_ID AND wposts.post_status=”publish” AND wcomments.comment_approved=’1′ AND wcomments.comment_date > DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 YEAR) GROUP BY wposts.ID ORDER BY comment_count DESC LIMIT 0 , 10 “;

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