Custom Post Type Category Page
-
Hello. I am having trouble with creating a category page for my custom post type.
Here is the function for my post type:
add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'backgrounds', array( 'labels' => array( 'name' => __( 'Backgrounds' ), 'singular_name' => __( 'Background' ), 'add_new' => __ ('Add Background'), 'add_new_item' => __ ('Add New Background') ), 'public' => true, 'has_archive' => true, 'supports' => array('title','editor','custom-fields', 'tags'), 'taxonomies' => array('post_tag','category'), 'menu_position' => 5, 'rewrite' => array('slug' =>'backgrounds','with_front' => true) ) ); flush_rewrite_rules(); }
Here is my wp_query:
<?php query_posts(array('post_type' => 'backgrounds', 'posts_per_page' => 10 )); ?> <?php while ( have_posts() ) : the_post(); ?> <a href="<?php the_permalink(); ?>"><div id="thumb" style="background: url(https://fresh-profile.com/backgrounds/<?php echo get_post_meta($post->ID, "file", $single = true); ?>) center center repeat;"> <div id="thumb-bg"></div> </div></a> <?php endwhile; ?>
But on the category page, it just displays all the posts, and doesn’t filter by the categories. Please help?
- The topic ‘Custom Post Type Category Page’ is closed to new replies.