Support » Fixing WordPress » List posts from custom post type

  • Hello,
    I have two custom post types. One is called “Tours” and another one is called “Hotels”. I wrote a custom widget to list all posts with post type “Tours” in my sidebar, so I do:
    $list_tours = new WP_Query('post_type=Tours');

    It works well. It returns the list of posts. However, if I’m on one of the single post from post type “Hotels” I cannot get a list of posts from “Tours” in my widget. It’s empty. I see the list on all categories, on single generic posts or pages, but only not under single post of other custom post type.

    Sorry, it’s difficult to explain. Any idea?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Looks like this is a bug in WP 3.0. In normal single posts or pages in ‘request’ I can find:
    element_type IN ('post_post','post_page','post_Tours','post_Hotels')

    When I go to single post of ‘Tours’ custom type I see:
    element_type IN ('post_Tours')

    So, widgets like “Recent Posts” to list posts from other post types don’t work. Does anyone reported something like that?



    This kind of thing is happening all the time on my site. that and other post type related stuff. I’m really having trouble figuring out what to do with it.
    The Post Type stuff could be really useful, but so many queries just seem built to ignore it or break when its concerned!

    I figured out a hard-coded method. I add a filter to ‘posts_request’ and change the part of query send to database. It works, but seems to be not a best solution. I hope, it will be fixed in next versions of WP.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘List posts from custom post type’ is closed to new replies.