I am having problems getting anything out of this while loop:

    $query_args = array(
        'post_type' => 'Smart panels',
        'posts_per_page' => 5,
        'orderby' => 'meta_value_num',
        'meta_key' => 'post_views_count'
    $query = new WP_Query($query_args);
    while($query->have_posts()) : $query->the_post();

        echo "<li>post</li>";

  • Welcome to WPSE :-). Side note: Please properly indent your code when adding it to the editor. Make your code as easy readable as possible for others. Proper details and properly added code usually attract good answers qiuckly – Pieter Goosen Sep 17 '14 at 15:39
  • 2
    That CAN'T be the name of your post type. – Tomás Cot Sep 17 '14 at 15:44
  • If you havent done so, please also read How to Ask, help center and visit our tour page – Pieter Goosen Sep 17 '14 at 15:45

Your post type is all wrong. Custom post type names cannot contain spaces or camelcase, also names should not contain special characters. Custom post type names, and for that matter, custom taxonomy names should be all lowercase letters, and names must only be separated by underscores (_)

Have a look at the $post_type parameter in register_post_type


(string) (required) Post type. (max. 20 characters, can not contain capital letters or spaces)

Default: None

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.