0

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

<ul>
    <?php
    $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>";

    endwhile; 
    ?>
</ul>
3
  • 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 Commented Sep 17, 2014 at 15:39
  • 2
    That CAN'T be the name of your post type.
    – Tomás Cot
    Commented Sep 17, 2014 at 15:44
  • If you havent done so, please also read How to Ask, help center and visit our tour page Commented Sep 17, 2014 at 15:45

1 Answer 1

1

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

$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 and acknowledge you have read our privacy policy.

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