[英]Adding a new BuddyPress menu item
add_action( 'bp_setup_nav', 'test_board', 100 );
function test_board() {
global $bp;
bp_core_new_nav_item( array(
'name' => 'Test Board',
'slug' => 'test-board',
'screen_function' => 'bpis_profile',
'position' => 10
)
);
}
function bpis_profile () {
echo do_shortcode('[bpis_tags]');
echo do_shortcode('[bpis_images]');
}
問題是,當我單擊BP導航欄中的此鏈接時,它將在任何div之外輸出短代碼(根據bpis_profile函數)(這意味着它僅出現在網站頂部,主題之外)。 此外,導航欄消失,並且我收到我當前正在查看的用戶的“關於”頁面(其中顯示了已訂閱的論壇主題,收藏的論壇主題等)。
有什么解決方法嗎? 理想情況下,我希望我的簡碼在BP導航欄(目前已消失)下方的正文區域中輸出。
謝謝!
嘗試這樣做:
function bpis_profile() {
bp_core_load_template( 'buddypress/members/single/posts' );
}
然后,您可以在buddypress/members/single/
下創建一個名為posts.php
的新文件。 在該文件內,您可以使用get_header
和get_footer
輸出整個頁面。 當然,請確保也包括您的短代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.