尝试以下操作:
function my_setup_nav() {
global $bp;
bp_core_new_nav_item( array(
\'name\' => __( \'My ads\', \'buddypress\' ),
\'parent_slug\' => $bp->profile->slug,
\'slug\' => \'myads\',
\'position\' => 30,
\'screen_function\' => \'my_item_one_template\',
\'default_subnav_slug\' => \'myads\'
) );
}
add_action( \'bp_setup_nav\', \'my_setup_nav\' );
function my_item_one_template() {
add_action( \'bp_template_content\', \'my_item_create_screen\' );
bp_core_load_template( apply_filters( \'bp_core_template_plugin\', \'members/single/plugins\' ) );
}
function my_item_create_screen() {
locate_template( array( \'buddypress/members/single/myads.php\' ), true );
}
放我的广告。此文件夹结构中主题或子主题中的php:
[theme]/buddypress/members/single/myads.php
如果仍然找不到模板,则必须注册模板,以便BP可以在模板堆栈中找到它。这可能相当复杂。更简单的方法是将代码直接放入函数中:
function my_item_create_screen() {
?>
<h2>MY ADS</h2>
<?php
}