New WordPress WP Query using posts from certain categories

There are some errors in your code, you have to change: $the_query -> have_posts() to $the_query->have_posts() $the_query -> the_post() to $the_query->the_post() WP_Query array(…) to WP_Query(array(…)) ‘showposts=6’ to ‘posts_per_page’ => 6 Try this instead $the_query = new WP_Query( array( ‘category_name’ => ‘portfolio’, ‘posts_per_page’ => 6 ) ); while ($the_query->have_posts()) : $the_query->the_post(); the_post_thumbnail(); endwhile;

shortcode for recent custom type post

This seems to work with custom post type : function get_custom_posts( $params ) { extract( shortcode_atts( array ( ‘number’ => ‘1’, ‘excerpt’ => 290, ‘readmore’ => ‘no’, ‘cpt’ => ‘post’, ‘readmoretext’ => ‘Read more’ ), $params ) ); //$latest_posts = get_posts( ‘category=0&numberposts=” . $number . “&suppress_filters=false’); OLD $latest_posts = query_posts( ‘post_type=”.$cpt.”&posts_per_page=” . $number ); wp_reset_query(); … Read more

wpdb get_var is not returning any result (verified mysql query returns only one value)

I guess meta_key is not a number, so you shouldn’t use %d in yous SQL query. $wpdb->prepare( “SELECT meta_value FROM %s WHERE user_id = %d AND meta_key = %s”,$userMeta,$user_id,$practiceKey ); // meta_key = %s not %d PS. You don’t have to escape table name in this way. You can use $wpdb->prepare( “SELECT meta_value FROM {$wpdb->usermeta} … Read more

Custom query to show posts

You can do it with wp_query $args = array( ‘post_type’ => ‘post’, ‘numberposts’ => -1, ‘posts_per_page’=> -1, ‘orderby’ => ‘meta_value_num’, ‘meta_key’ => ‘ratings_average’, ‘order’ => ‘DESC’, ); $posts = new WP_Query($args); Now the result is DESC Order.

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