• Resolved DolphinGuy

    (@sanyadolpins)


    Hi,

    Great plugin. Makes setting up Custom Post much easier. However, if I select a Category created in the WP Post Add Categories from the Custom Post sidebar, the Custom Post does not show up on the Category pages. If I make a WP Post from the standard WP Add New Post, it shows up as it normally does. What am I missing? How do I get my Custom Posts to show up in the WP Category Taxonomy?

    Thanks!

Viewing 1 replies (of 1 total)
  • Plugin Author Cristian Antohe

    (@sareiodata)

    Hi, that’s because the default category archive query doesn’t take into account custom post types, only posts.

    To change that you’ll need to:

    * Create an empty plugin like this: https://gist.github.com/sareiodata/76f701e01db6685829db
    * Add the following code to the end of it:
    *

    
    add_action( 'pre_get_posts', 'add_my_custom_post_type' );
    /**
     * @param WP_Query $query
     * @return WP_Query
     */
    function add_my_custom_post_type( $query ) {
        if ($query->is_main_query()) 
            $query->set( 'post_type', array( 'post', 'page', 'any_custom_type' ) );
        return $query;
    }
    

    * Install this plugin via FTP (copy it inside wp-content/plugins) or create a zip archive with it and install it via the WordPress plugin upload functionality

Viewing 1 replies (of 1 total)
  • The topic ‘Not showing in Categories’ is closed to new replies.