Might be related to your component, but probably just the usual cpt issues.
Do you have a theme template called single-music.php so that WP can display it?
Do you have a pre_get_posts filter in your theme/functions.php or plugin file so that WP knows you want a cpt?
// so music cpt is included in cat or tag calls
function stoi_query_post_type($query) {
if(is_category() || is_tag()) {
$post_type = get_query_var('post_type');
if($post_type)
$post_type = $post_type;
else
$post_type = array('post','music');
$query->set('post_type',$post_type);
return $query;
}
}
add_filter('pre_get_posts', 'stoi_query_post_type');
I dont have a pre_get_posts for other post types I have defined, but those also do not have a bp component associated with them (those display just fine). I do not have a single-music.php file nor do I have a single-track.php file, however when I change my slug to track all is good. Like I said all of this worked in a previous theme I was using but now that I am writing a new theme things are not working for my single posts only for this custom post type which has an associated bp component and a page called music which this component is associated with.
Thanks,
Jesse
I found that my custom post type and page Im using for the archive have the same slug. I have read in various places that this commonly causes a 404 error. I added a submenu item for single posts to display under the pages slug like so.
$single_item_link = $bp->current_item;
if ( bp_is_my_custom_component() && bp_is_single_item() ) {
// Reset sub nav
$sub_nav = array();
// Add single music page but dont display in navigation
$main_nav = array(
'name' => __( 'Single Music', 'bp-music' ),
'slug' => $single_item_link,
'position' => -1, // Do not show in BuddyBar
'screen_function' => 'custom_component_screen_single',
'default_subnav_slug' => $this->default_extension,
'item_css_id' => $this->id
);
}
This menu item loads a function in the screens file of the component
function custom_component_screen_single() {
if ( ! bp_is_single_item() )
return false;
$bp = buddypress();
do_action( 'custom_component_screen_single' );
bp_core_load_template( apply_filters( 'custom_component_screen_single', 'custom-component/single/home' ) ); //this loads a template file within the template folder of the component or within the theme
}
And for now all is good. I would still like to find a way to load my custom taxonomy into the permalink structure so things would look like this.
mydomain.com/custom-component/custom-taxonomy/single-item
If anyone has any ideas on how I can get this to work as well please let me know. My guess is I could make another menu item to capture that instance and if the genre exists then it loads a template file. Then I need to find a way to make sure a single item and a custom taxanomy dont end up with the same name.
Thanks,
Jesse