Ouch, banging my head against a wall!

I am trying to query my post type 'clips' in index.php but it's returning only posts from the default 'post'. I need some insight! What am I doing wrong?

My post type:

$args = array( 
    'labels' => $labels,
    'supports' => $supports, 
    'hierarchical' => false,
    'menu_position' => 4,
    'publicly_queryable' => true,
    'show_ui' => true,
    'public' => true,
    'query_var' => true,
    'capability_type' => 'clip',
    //'map_meta_cap' => true,
    //'capabilites' => $capabilities,

register_post_type( 'clip', $args ); 

My query (index.php):

<?php query_posts(array('posts_per_page' => 17, 'post_type' => array('clip'))); ?>

<?php if (have_posts()) : ?>

<ul id="clips" class="clearfix reset">

  <?php while (have_posts()) : the_post(); ?>

      <?php the_title();?><br><?php the_permalink(); ?>
      <a id="post-<?php the_id(); ?>" class="videolink" title="Click to view" href="">
      <?php if ( has_post_thumbnail() ) { 
        } else { 
        echo "No thumbnail"; 
        } ?></a>

   <?php endwhile; ?>


    <?php else: ?>

        <p>Sorry, but this content is not available.</p>

    <?php endif; ?>

Note there are no other loops in the template file.

  • On what context are you registering your post type? functions.php, in a plugin file? Which action are you using to call these functions? – tollmanz Aug 31 '11 at 4:20
  • On closer inspection ANY post apart from type 'post' is failing to return anything using standard functions. Woah! Gotta find out what's going on there. Back soon. – Niels Aug 31 '11 at 4:22
  • functions.php has an include to the file with the code. Action is 'init'. How might that affect the output? – Niels Aug 31 '11 at 4:23
  • Don't know what it was and unfortunately I don't have time to look deeper but a clean db fixed the issue. :-/ – Niels Aug 31 '11 at 5:30
  • It seems like you forgot to post the full function of your register_post_type or else that is the problem. – Wyck Aug 31 '11 at 5:38

I had a similar problem and posted the solution here:


query_posts causes the main WP_Query to be discarded. That may or may not be the behavior you want. If no, you need to update WP_Query, then you could update your functions.php file to include a register filter that displays your content types as part of WP_Query (see code at URL above). If yes, you don't care about WP_Query, then I ran my query_posts after have_posts with this code in my index.php file:

    query_posts(array('post_type' => array('post', 'article', 'document', 'faq', 'video')));
  • Yes, yes! that makes sense! Thanks for the insight! – Niels Sep 1 '11 at 6:37

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.