• Hi guys,

    I’ve got a problem that i’ve been trying to solve for weeks now. Basically, i’m building a CMS based site. First a bit of background:

    The site uses two custom post types; “profiles” and “minutes”. I’ve defined these in the functions.php file in my theme.

    I also have two categories defined; “Profiles” and “Minutes”.

    I can successfully create new posts from the dashboard etc. and i tag them by their respective category.

    I also use the “more fields” plugin to define custom data fields for use with the “profiles” post type. They all seem to work fine with the post type.

    The Problem:

    I’m trying to use two seperate single-(posttype).php files for each of the post types to display thier contents. But get this: the “Profile” file works fine but the “Minutes” one doesn’t, it just returns a 404. Here’s the single.php code i’ve got it place to ‘route’ the post types:

    <?php
    	$post = $wp_query->post;
    	if (in_category('Profiles')) {
    	include (TEMPLATEPATH . '/single-profile.php');
    	}
    	elseif (in_category('Minutes')) {
    	include (TEMPLATEPATH . '/single-minute.php');
    	}
    	else {
    	include (TEMPLATEPATH . '/single-default.php');
    	}
    ?>

    Now, I’ve tried swapping round the files to test that the single-minute.php file successfully renders in the browser and it does.

    I’m a little stuck and have tried a variety of different ways to route the posts to the different single files but to no avail.

    Can anyone please help!?

    thanks
    wishy

Viewing 1 replies (of 1 total)
  • Thread Starter wishypw

    (@wishypw)

    thought i’d post up some more details on this based on possible causes:

    my permalink structure is:

    /%category%/%postname%/

    and as i’ve mentioned, it works for one category just not the other.

    also, my custom post-types defined in the functions.php are as follows:

    // Adds Custom Post Types "Profiles" and "Minutes".
    /* Profiles */
    add_action('init', 'register_profiles');
    function register_profiles() {
        $args = array(
    	'name' => __('Profiles'),
            'label' => __('Profiles'),
            'singular_label' => __('Profile'),
            'public' => true,
            'show_ui' => true,
    	'_builtin' =>  false,
            'capability_type' => 'post',
            'hierarchical' => false,
    	'rewrite' => array('slug' => 'profiles'),
    	'query_var' =>  true,
            'supports' => array('title', 'thumbnail',)
           );  
    
        register_post_type( 'Profile' , $args );
    } 
    
    /* Meeting Minutes */
    add_action('init', 'register_minutes');
    function register_minutes() {
        $args = array(
    	'name' => __('Minutes'),
            'label' => __('Minutes'),
            'singular_label' => __('Minute'),
            'public' => true,
            'show_ui' => true,
    	'_builtin' =>  false,
            'capability_type' => 'post',
            'hierarchical' => false,
    	'rewrite' => array('slug' => 'minutes'),
    	'query_var' =>  true,
            'supports' => array('title', 'editor', 'thumbnail')
           );  
    
        register_post_type( 'Minute' , $args );
    } 
    
    // Adds category box to edit screens.
    add_action('init', 'add_category_boxes');
    function add_category_boxes() {
    	register_taxonomy_for_object_type('category','Profile');
    	register_taxonomy_for_object_type('category','Minute');
    }

    cheers

Viewing 1 replies (of 1 total)
  • The topic ‘single redirection by cat – one cat works the other doesn't’ is closed to new replies.