INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Two category pages?

Two category pages?

(OP)
I have created a custom post type for 'classes', the posts within this will be mostly without category however 4 posts will be with the category 'spin'.

On page /classes/ all posts are shown (those with no category set and those in category 'spin').

Can I set it so that the spin classes only appear on the spin archive page i.e. remove them from the classes archive page?

Here is how I created my cpt

CODE

// Register Classes Custom Post Type
function classes_post_type() {

	$labels = array(
		'name'                  => 'Classes',
		'singular_name'         => 'Class',
		'menu_name'             => 'Classes',
		'name_admin_bar'        => 'Classes',
		'archives'              => 'Class Archives',
		'parent_item_colon'     => 'Parent Class:',
		'all_items'             => 'All Classes',
		'add_new_item'          => 'Add New Class',
		'add_new'               => 'Add New Class',
		'new_item'              => 'New Class',
		'edit_item'             => 'Edit Class',
		'update_item'           => 'Update Class',
		'view_item'             => 'View Class',
		'search_items'          => 'Search Classes',
		'not_found'             => 'Not found',
		'not_found_in_trash'    => 'Not found in Trash',
		'featured_image'        => 'Main Image',
		'set_featured_image'    => 'Set main image',
		'remove_featured_image' => 'Remove main image',
		'use_featured_image'    => 'Use as main image',
		'insert_into_item'      => 'Insert into class',
		'uploaded_to_this_item' => 'Uploaded to this class',
		'items_list'            => 'Class list',
		'items_list_navigation' => 'Classes list navigation',
		'filter_items_list'     => 'Filter classes list',
	);
	$args = array(
		'label'                 => 'Classes',
		'description'           => 'Classes section',
		'labels'                => $labels,
		'supports'              => array( 'title', 'editor', 'thumbnail' ),
		'taxonomies'            => array( 'category', 'post_tag' ),
		'hierarchical'          => false,
		'public'                => true,
		'show_ui'               => true,
		'show_in_menu'          => true,
		'menu_position'         => 20,
		'show_in_admin_bar'     => true,
		'show_in_nav_menus'     => true,
		'can_export'            => true,
		'has_archive'           => true,		
		'exclude_from_search'   => false,
		'publicly_queryable'    => true,
		'capability_type'       => 'page',
	);
	register_post_type( 'classes', $args );

}
add_action( 'init', 'classes_post_type', 0 ); 

Thank you

RE: Two category pages?

Quote:

On page /classes/ all posts are shown (those with no category set and those in category 'spin').

Clarification needed, ...

Does "all posts are shown" mean;

literally all posts?

OR

"all posts of type 'Classes' "?

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: Two category pages?

(OP)
All posts of type classes, sorry.

I noticed that my 'spin' category is also appearing in Posts > category. I thought the category would be unique to classes?

RE: Two category pages?

Quote:

I thought the category would be unique to classes?
categories are categories ... ... post types are post types, ... ... Even where the twain do meet.

They are both methods of segregating and organising entries and are not mutually exclusive.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: Two category pages?

(OP)
Do you think it is possible to exclude 'spin' classes from the main archive-classes.php results?

RE: Two category pages?

So going back to the original;

You seem to be confusing post "types" and post "categories", the two are separate (b)log entry taxonomies.

Displaying a collection of posts of [type] will include all categories and uncategorised entries.

Displaying a collection of posts in [category] will include all post 'types' entries.

If you want only entries of [type] AND NOT [category] you need to write the appropriate WP_Query parameters

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: Two category pages?

(OP)
Aha yes that makes sense thanks.

The /category/spin/ page 404's, I tried resetting the permalinks without luck so alos tried setting it to the default so that the /classes/ post type now displays as

domain.com/?post_type=classes (works fine still showing the age layout from archive-classes.php)
domain.com/?cat=1 (gives 404 despite having classes assigned to the spin category)

I don't understand why the page is 404 ing.

RE: Two category pages?

(OP)
Update:

I used the Advanced Category Template plugin https://wordpress.org/plugins/advanced-category-te... to help create a specific template for the category.

When I view

http://domain.com/?cat=1

I see the template I created. However when I add the loop in here

CODE

<?php if (have_posts()) : ?>
            
<?php while (have_posts()) : the_post(); ?>
            
<?php the_title(); ?>
            
<?php endwhile; ?>
    
<?php else : ?>

<h1>Nope, nothing found</h1>

<?php endif; ?> 

I get Nope, nothing found. How come it isn't displaying the posts, I see in wordpress that 6 posts have been assigned this category.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close