Please check the code below. I guess you are facing 404 because it’s not getting the slug
& the url
properly.
add_action( 'bp_setup_nav', 'mb_bp_profile_menu_posts' );
function mb_bp_profile_menu_posts() {
global $bp;
bp_core_new_nav_item(
array(
'name' => 'My Posts',
'slug' => 'myposts',
'position' => 11,
'default_subnav_slug' => 'published',
'screen_function' => 'mb_author_posts',
'parent_url' => bp_displayed_user_domain() . '/myposts/',
'parent_slug' => $bp->profile->slug,
'default_subnav_slug' => 'myposts',
)
);
}
function mb_author_posts() {
add_action( 'bp_template_title', 'mb_author_posts_title' );
add_action( 'bp_template_content', 'mb_author_posts_content' );
bp_core_load_template( 'buddypress/members/single/plugins' );
}
function mb_author_posts_title() {
echo 'My Posts';
}
function mb_author_posts_content() {
echo 'Content logic goes here...';
}