Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Custom Component Help

@stoi2m1

Participant

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

Skip to toolbar