Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm working on an exchange site of sorts where people will be able to list or request surplus items inside of our organization. Listings will just be submitted as 'posts' but I've created a custom post type 'request' for requests and it seemed to be working fine; I'm displaying the requests on a page with my own little loop that shows the post title, excerpt, thumb and category (Both 'posts' and 'requests' share the same category taxon.)

The problem is, I can't seem to view the 'requests' by category in the same blog style format that I can with posts. If I click on the category next to a request, It takes me to the 'posts' with that category.

This seems like it would be pretty basic so I'm not sure what I'm missing. I can go to mysite.com/category/mycategory to see all of my listings ('posts') by category and I can go to mysite.edu/request to see all the requests but I can't just sort requests by category.

Just in case, here's my custom post type code. Also, I have not selected a blog page in settings, I just left it blank - I don't think that really makes a difference, I just thought I would mention. One more thing, If I include a category widget in the sidebar, it includes both 'posts' and 'requests' in the post count but if I click the link, obviously, it just goes to the 'posts' in that cat.

<?php
    /*
    Plugin Name: U Custom Post Types
    Plugin URI: http://mysite.edu
    Description: Creates custom post types
    Version: 0.1
    Author: Me
    Author URI: http://mysite.edu
    */

function my_custom_post_request() {
    $labels = array(
        'name'               => _x( 'Requests', 'post type general name' ),
        'singular_name'      => _x( 'Request', 'post type singular name' ),
        'add_new'            => _x( 'Add Request', 'request' ),
        'add_new_item'       => __( 'Add New Request' ),
        'edit_item'          => __( 'Edit Request' ),
        'new_item'           => __( 'New Request' ),
        'all_items'          => __( 'All Requests' ),
        'view_item'          => __( 'View Request' ),
        'search_items'       => __( 'Search Requests' ),
        'not_found'          => __( 'No requests found' ),
        'not_found_in_trash' => __( 'No requests found in the Trash' ), 
        'parent_item_colon'  => '',
        'menu_name'          => 'Requests'
    );
    $args = array(
        'labels'        => $labels,
        'description'   => 'Holds our requests and request specific data',
        'public'        => true,
        'menu_position' => 5,
        'supports'      => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
        'has_archive'   => true,
        'taxonomies'        => array('category'),
        'capabilities'  => array(
                                                'publish_posts' => 'publish_requests',
                                                'edit_posts' => 'edit_requests',
                                                'edit_others_posts' => 'edit_others_requests',
                                                'delete_posts' => 'delete_requests',
                                                'delete_others_posts' => 'delete_others_requests',
                                                'read_private_posts' => 'read_private_requests',
                                                'edit_post' => 'edit_request',
                                                'delete_post' => 'delete_request',
                                                'read_post' => 'read_request',
                                            ),
    );
    register_post_type( 'request', $args ); 
}
add_action( 'init', 'my_custom_post_request' );

?>
share|improve this question
1  
Related: wordpress.stackexchange.com/a/91263/21376 –  s_ha_dum Jul 11 '13 at 14:39
    
Thanks, but it seems like that may be a little bit more complex than what I'm trying to accomplish. I can't imagine that much code being required just to tap in to the existing wordpress loop functionality. –  ItsGeorge Jul 11 '13 at 18:44
2  
"The existing WordPress Loop functionality" does not support ordering by a category. There are other ways to do it-- filters on posts_join and 'posts_where`-- but none that I know of that are less complicated or require less code. –  s_ha_dum Jul 11 '13 at 20:17
    
Thanks for the hard truth. At least now I have a starting point. I'm sure a bunch of people have already dealt with this. Surely it's not uncommon for a site to have multiple sortable post types. –  ItsGeorge Jul 15 '13 at 18:30
    
I'm making some progress here. I've created a custom template with a custom loop for a specified taxonomy and category. That part is working and wasn't too difficult. Now I just need to figure out a way to abstract it out so that the results can be determined by the url. –  ItsGeorge Jul 16 '13 at 15:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.