嗨,我已经试着解决这个问题有一段时间了,并在谷歌和其他地方进行了搜索。
我在buddypress的个人资料区创建了一个新的菜单项。当我点击新的主菜单项时,它会转到正确的功能/页面,但当我点击子菜单项时会转到404页面。
我知道子菜单正在处理该功能,但它似乎进入了404页面。这是我在bp-custom.php 中输入的代码
function profile_new_nav_item() {
global $bp;
bp_core_new_nav_item(
array(
'name' => 'eBlurts',
'slug' => 'eblurts',
'default_subnav_slug' => 'eblurt-activity', // We add this submenu item below
'screen_function' => 'view_manage_tab_main'
)
);
}
add_action( 'bp_setup_nav', 'profile_new_nav_item', 10 );
function view_manage_tab_main() {
add_action( 'bp_template_content', 'bp_template_content_main_function' );
bp_core_load_template( 'template_content' );
}
function bp_template_content_main_function() {
if ( ! is_user_logged_in() ) {
wp_login_form( array( 'echo' => true ) );
}
}
function profile_new_subnav_item() {
global $bp;
bp_core_new_subnav_item( array(
'name' => 'eBlurt Activity',
'slug' => 'eblurt-activity',
'parent_url' => $bp->loggedin_user->domain . $bp->bp_nav[ 'eblurts' ][ 'slug' ] . '/',
'parent_slug' => $bp->bp_nav[ 'eblurts' ][ 'slug' ],
'position' => 10,
'screen_function' => 'eblurt_activity'
//'link' => bp_get_activity_directory_permalink()
) );
bp_core_new_subnav_item( array(
'name' => 'Write eBlurt',
'slug' => 'write-eBlurt',
'parent_url' => $bp->loggedin_user->domain . $bp->bp_nav[ 'eblurts' ][ 'slug' ] . '/',
'parent_slug' => $bp->bp_nav[ 'eblurts' ][ 'slug' ],
'position' => 20,
'screen_function' => 'write_eblurt'
//'link' => $bp->loggedin_user->domain . $bp->bp_nav[ 'eblurts' ][ 'slug' ] . '/write-eBlurt/'
) );
}
add_action( 'bp_setup_nav', 'profile_new_subnav_item', 10 );
function eblurt_activity() {
//bp_get_template_part( 'template_content' );
add_action( 'bp_template_content', 'eblurt_content' );
//bp_get_template_part( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
//bp_get_template_part( 'eblurts' );
//echo 'has it reached here';
}
function write_eblurt() {
//echo 'here now';
//bp_get_template_part( 'template_content' );
bp_get_template_part( 'members/single/plugins' );
add_action( 'bp_template_content', 'eblurt_content' );
//bp_core_redirect( get_option('siteurl') . "/videos/" );
//echo 'this is where it is';
//bp_core_load_template( 'template_content' );
//bp_get_template_part( 'eblurts' );
}
function eblurt_content(){
bp_get_template_part( 'eblurts' );
}
我在评论中留下了一些我尝试过的东西。此外,我把文件"eburts.php"放在我的主题文件夹中。它似乎确实到达了它,因为它正在回显文件中的文本。
任何帮助或尝试的东西都将不胜感激,我快疯了,哈哈。或者,如果有更好的方法来做我想做的事情,那基本上就是——在个人资料区域有一个菜单项,可以转到我有表单供用户提交的页面一些东西。
感谢
当然,我在过去的几天里一直在寻找为什么这不起作用,在发布这个问题一个小时后,我就明白了。
不管怎样,在子菜单的函数中,你必须使用"bp_core_load_template"而不是"bp_get_template_part"
更改:
bp_get_template_part( 'template_content' );
收件人:
bp_core_load_template( 'template_content' );
因此,希望少数人得到同样的错误,这将有助于解决。