Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom post types called publications. I want to retrieve all the pages and publications. (I'm also filtering by taxonomy, but that's not what is creating the problem)

$args= array(
        'post_type'=>array('publications', 'page')
        );
query_posts($args);

The above only returns pages, not publications. If I remove 'page' from the array and leave

'post_type'=>array('publications')

then the publications are returned.

Its seems like I cannot query more than I post type at a time, contrary to what the codex explains here: http://codex.wordpress.org/Template_Tags/query_posts#Type_.26_Status_Parameters. I've tried 'post_type' = 'any' with the same results; only the pages are returned. Using WP_Query also yielded the same results.

Am I doing something wrong or is this a bug in WP 3.1 rc3?

share|improve this question
    
[resolved] Translation of custom post types had to be enabled in WPML settings. here's how –  Bundarr Feb 2 '11 at 13:06
add comment

1 Answer

up vote 1 down vote accepted

Hi @Bundarr:

Testing the following basic example as a standalone file it looks like it works as expected and not as you are reporting:

<?php

include '../wp-load.php';
header('Content-type: text/plain');
$q = new WP_Query(array(
  'post_type'=>array('publications', 'page')
  'posts_per_page' => -1,
));
echo "SQL: {$q->request}\n";
foreach($q->posts as $post) {
  echo "{$post->post_name} - {$post->post_type}\n";
}

So, I can only assume that you have some plugins or theme code that is somehow blocking?

Or maybe it is as simple as missing a 'posts_per_page' => -1 argument and thus only displaying a limited number and making it seem like it's not working? With 'posts_per_page' the query would look like this (-1 means 'no limit'):

$q = new WP_Query(array(
  'post_type'=>array('publications', 'page')
  'posts_per_page' => -1,
));
share|improve this answer
1  
Thanks Mike for pointing me in the right direction. By looking at the SQL statement it is clear that the problem is coming from the WPML plugin - custom post_types dont have mutilingual enabled as of yet. T –  Bundarr Jan 31 '11 at 11:51
    
@Bundarr - Cool. Glad to help. Submit a trac ticket then? –  MikeSchinkel Jan 31 '11 at 12:43
    
It's my oversight. Ive pointed to the solution in a comment to my question. –  Bundarr Feb 2 '11 at 13:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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