WordPress.org

Ready to get started?Download WordPress

Forums

List posts from custom post type (4 posts)

  1. rafalt
    Member
    Posted 4 years ago #

    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?

  2. rafalt
    Member
    Posted 4 years ago #

    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?

  3. Ian
    Member
    Posted 4 years ago #

    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!

  4. rafalt
    Member
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic