WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type UI
[resolved] I can't view custom posts from a category (10 posts)

  1. MCosmin
    Member
    Posted 1 year ago #

    Hi,

    I created some custom posts with this plugin and I put Categories as a Built-in Taxonomies.

    When I enter in the categories I can't see my articles from custom posts. I can see only normal posts. Any idea how to solve this?

    http://wordpress.org/extend/plugins/custom-post-type-ui/

  2. Michael Beckwith
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  3. MCosmin
    Member
    Posted 1 year ago #

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

  4. Michael Beckwith
    Member
    Plugin Author

    Posted 1 year ago #

    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

  5. MCosmin
    Member
    Posted 1 year ago #

    Thanks a lot! I will check the tutorial.

  6. MCosmin
    Member
    Posted 1 year ago #

    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?

  7. Michael Beckwith
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  8. MCosmin
    Member
    Posted 1 year ago #

    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?

  9. Michael Beckwith
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  10. MCosmin
    Member
    Posted 1 year ago #

    Thanks Michael.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.