Tagged: buddyblog, simple-frontend-post
- Hi there, - I’m wondering is there anyway to add New Post link to the main menu? I found something like this: - add_filter( 'wp_nav_menu_items', 'my_nav_menu_profile_link' ); function my_nav_menu_profile_link($menu) { if (!is_user_logged_in()) return $menu; else $profilelink = '<li><a href="' . bp_loggedin_user_domain( '/' ) . '">' . __('My Profile') . '</a></li>'; $menu = $menu . $profilelink; return $menu; }- But obviously, it can’t work with any theme. - Could you help me out? -  This topic was modified 9 years, 10 months ago by Brajesh Singh. Reason: Updating code block 
 
-  This topic was modified 9 years, 10 months ago by 
- Hi Toan, 
 Please put this code in your bp-custom.php or functions.php of your theme and let me know if it works.- add_filter( 'wp_nav_menu_items', 'buddyblog_custom_newpost_link' ); function buddyblog_custom_newpost_link($menu) { if ( ! is_user_logged_in() ) { return $menu; } if( function_exists( 'buddyblog_get_home_url' ) ) { $new_post_url = buddyblog_get_home_url( get_current_user_id() ) . 'edit' ; $menu = $menu . '<li><a href="' . $new_post_url . '">' . __('Create Post') . '</a></li>'; } return $menu; }- Hope that helps. - Regards 
 Brajesh
- Hi Brajesh, - Thanks for your response, it’s working, obviously. But what if I want to add the new_post_url before or after an element in my menu. - For example: Profile | New Post | Logout 
 Logout is a custom link came with my theme, (in secondary menu)- Regards, 
 Toan.
- Hi, 
 That will be beyond this plugin. The solution is using a solution like page links to( Creating a page and on click redirecting to the new post screen) and using some type of plugin to add/remove the menu when user is logged in/not logged in( This is not built into WordPress).
You must be logged in to reply to this topic.