Support » Themes and Templates » Custom post type tags/categories archive page

  • Leads



    I’ve been playing with custom post types, and whilst initially I’m impressed with them, I have a few issues.

    I have converted some posts to custom type, and have have given them a category and some tags. This display fine and have hyperlinks. However, when I click the hyperlink, I get the archive page of the tag, but only posts from that tag (or category), not from my custom post type.

    What do I need to do?

Viewing 15 replies - 16 through 30 (of 39 total)
  • Big thanks to the clever folk on this thread. I had this exact problem, including the nav issue. Now solved.


    Are you using clean urls? if so turn them off, use the nasty ones for now, test this out. see if it works. if it works then the issue is in the url and “routing” if not the issue is else where.

    Used parandroid’s fix. Worked great but got the same nav-bar issue as everyone else.

    Tried Ryansigg’s solution and now my menu is just a vertical list. I.e. No css customizing of it at all.

    Never mind. Seems to have been a one time glitch. Sorry about that. Everything looks beautiful.

    If your like me your using multiple CPT’s and may run into other “issues”, this is what I added to sovle mine:

    $post_types = get_post_types();

    Doing a print_r on this returns the following:

        [0] => post
        [1] => page
        [2] => attachment
        [3] => revision
        [4] => nav_menu_item
        [5] => article

    As you can see it __should__ basically cover everything, it maybe slow if your using multiple CPT’s or there may be unwanted effects.

    Here is the updated code:

    $post_types = get_post_types();
        if ( is_category() || is_tag()) {
            $post_type = get_query_var('article');
            if ( $post_type )
                $post_type = $post_type;
                $post_type = $post_types;
            $query->set('post_type', $post_type);
        return $query;


    ok, my pb is close to be the same :
    I would like to share same categories referentiel between my posts and those who belong to my custom post type (named ‘Portolio’)
    Actually, when i’ve registered the ‘Portfolio’ type, i’ve associated it to a “new” category referentiel (ie. different from the classic post category)
    My question is : i want the same categories referentiel than the classic post type.
    Have you got an idea ?
    Thanks for your reply!



    ok i’ve found the solution : you have to use the function
    register_taxonomy_for_object_type(‘category’, ‘Portfolio’);
    with category, a taxonomy ever registered for posts.

    That’s exactly how I was doing it and it worked for me.

    Same Problem and this code works just great. (parandroid code)
    Better than “Custom Post Type Viewer” plugin wich do the stuff but also mix Posts and Custom Post Type Posts in the homepage.

    Just want to say thanks for that.

    I used the code as described above but now my menus are gone. Does anyone have a clue how to get them back?

    With menu:
    Menu gone:


    I used the code paranoid provided and also ryansigg’s fix, but now i have another problem when displaying the posts from a category. I use a function that displays the thumbnail of every post, but with this code the thumbnail disappears. Anyone any ideas ?

    Can you paste this function?

    If it is over 10 lines long, please use the pastebin.

    function imaginii1($postID) {
       $arrImages =& get_children('post_type=attachment&post_mime_type=image&post_parent=' . $postID );
       if($arrImages) {
               // Get array keys representing attached image numbers
               $arrKeys = array_keys($arrImages);
               $sThumbUrl = wp_get_attachment_thumb_url($arrKeys[0]);
               // Build the <img> string
               $sImgString = '<a href="' . wp_get_attachment_url($arrKeys[0]) . '">' .
                       '<img src="' . $sThumbUrl . '" alt="" title="" />' .
               echo $sImgString;

    [Please post code snippets between backticks or use the code button.]

    I’d do a print_r or var_dump on $arrImages and start there

Viewing 15 replies - 16 through 30 (of 39 total)
  • The topic ‘Custom post type tags/categories archive page’ is closed to new replies.