Support » Fixing WordPress » Custom Post Type and Category.php

  • Ok, been at this now since 9pm last night!! I created a custom post type called ‘scrapbooks’. Added the default WP category to this post type using:

    add_action( 'init', 'wpse6098_init', 100 ); // 100 so the post type has been registered
    function wpse6098_init()
        register_taxonomy_for_object_type( 'category', 'scrapbooks' );

    Anyway, that works great, displays cats, etc etc. The problem comes when Iclick on a cat to view all posts in that cat, it just displays EVERY post in the custom post type. Now I have tried everything I can think of to fix this, but no joy.

    I even tried custom category templates and that didnt work, so am back to using the standard category.php (it isn’t called anywhere else) and that is

    <?php get_header(); ?>
    <div class="page-overlay">
    <div id="page-wrapper"><div class="fake-close"><a title="Pop-up Books from Sussex Paper Engineer" href=""><img src="" alt="Close" /></a></div>
    <div id="diary-page-wrapper">
    <div id="diary-top"></div><!-- /#diary-top -->
    <div id="diary-middle">
    <div id="diary-left">
    <?php query_posts('post_type=scrapbooks'); while (have_posts()) : the_post(); ?>
    <div class="diary-date-info"><span class="times-new-roman"><?php the_time('M n') ?> | </span><?php the_category(' '); ?></div><!-- /.diary-date-info -->
    <div class="diary-post-content">
    <h1><?php the_title(); ?></h1>
    <?php the_content(); /* Print the content we just got */ ?>
    </div><!-- /.diary-post-content -->
    <?php endwhile; ?>
    </div><!-- /#diary-left -->
    <div id="diary-right">
    <div class="diary-right-header"><span class="times-new-roman">Notes |</span></div><!-- /.diary-right-header -->
    <div id="diary-right-float">
    <div class="diary-right-float-left"><img class="diary-float-left-img" src="" alt="The Bookshelf" title="The Bookshelf"><span class="diary-float-left-desc">THE BOOKSHELF</span><img class="diary-float-left-img" src="" alt="Basil, the studio Dog" title="Basil, the studio Dog"><span class="diary-float-left-desc">THE STUDIO DOG (Basil)</span><img class="diary-float-left-img" src="" alt="Corina Fletcher" title="Corina Fletcher"><span class="diary-float-left-desc">CORINA</span></div><!-- /.diary-right-float-left -->
    <div class="diary-right-float-right"><div class="diary-right-categories"><ul><li>Category Index:</li><?php wp_list_cats('exclude=1'); ?></ul></div><!-- /.diary-right-categories --><img class="diary-float-left-img" src="" alt="Corina's Paper Engineering tools" title="Corina's Paper Engineering tools"><span class="diary-float-left-desc">THE TOOLS</span><img class="diary-float-left-img" src="" alt="The Elf, Lydia" title="The Elf, Lydia"><span class="diary-float-left-desc">THE ELF (Lydia)</span></div><!-- /.diary-right-float-right -->
    </div><!-- /#diary-right-float -->
    </div><!-- /#diary-right -->
    </div><!-- /#diary-middle -->
    <div id="diary-bottom"></div><!-- /#diary-bottom -->
    </div><!-- /#diary-page-wrapper -->
    </div><!-- /#page-wrapper -->
    </div><!-- /.page-overlay -->
    <?php get_footer(); ?>

    Really getting tired of this now, seems like the last hurdle lol.

Viewing 1 replies (of 1 total)
  • Moderator keesiemeijer



    Is this the category.php you have now?
    this part query_posts('post_type=scrapbooks'); tells the loop to only show “scrapbooks” Post type Posts.
    Maybe you need:

    $current_cat = get_query_var('cat');

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Post Type and Category.php’ is closed to new replies.