Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    You’re going to need to use a filter like pre_get_posts http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts to get them in the original query. The custom post types don’t show up in the posts listings by default after registering them.

    Thread Starter MCosmin

    (@mcosmin)

    It is a little difficult for me. 🙁
    But can I see original post and also custom post in the same category?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    You can, just not by default out of the box, you need to make your theme query for the custom post types as well. Right now in your posts stream, it’s just querying for the post type of “post”, you need to make it query for “post” and whatever your registered post type is. This is why i suggested the filter above, so you can get it doing that.

    Check out this quick tutorial for some more info http://www.wprecipes.com/how-to-display-custom-post-types-on-your-wordpress-blog-homepage

    Thread Starter MCosmin

    (@mcosmin)

    Thanks a lot! I will check the tutorial.

    Thread Starter MCosmin

    (@mcosmin)

    I read this tutorial. It said to put this code in function.php
    —–
    add_filter( ‘pre_get_posts’, ‘my_get_posts’ );
    function my_get_posts( $query ) {
    if ( is_home() && false == $query->query_vars[‘suppress_filters’] )
    $query->set( ‘post_type’, array( ‘post’, ‘page’, ‘album’, ‘movies’, ‘attachment’ ) );
    return $query;
    }
    —–

    I wrote this code in function.php and I created a post type with the name movies. But I still can’t see custom post in my home page, only original posts. Can you tell me what should I do?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    you could probably remove the album and attachment parts from the $query->set() line.

    Otherwise, I believe that should work, so I’m not quite sure why it’s not.

    Thread Starter MCosmin

    (@mcosmin)

    No, I can’t see custom posts with only the code inserted in function.php

    But I succeeded to view custom posts in home page inserting <?php query_posts( 'post_type=movies'); ?> in index.php.
    But I can’t see original posts anymore. 🙂

    Can I see in the same page both posts: custom and original?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Like i said, it very well SHOULD be possible, why it’s NOT with the pre_get_posts() way is something i’m not sure about for why it’s not working.

    The query_posts() method I highly advise against.

    Hopefully someone else can chime in with this or if you’re an IRC user, check out #wordpress on freenode. This issue isn’t one with the UI plugin itself, but more display of content from your DB.

    Thread Starter MCosmin

    (@mcosmin)

    Thanks Michael.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘I can't view custom posts from a category’ is closed to new replies.