Add Member Links and ShortCode


/ Published in: HTML
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // Filter to add new myprofile link to nav menu
  2.  
  3. function new_nav_menu_items($items) {
  4. $profilelink = '<li id="my-profile" class="my-profile"><a href="' . bp_loggedin_user_domain() . '"> MyProfile</a></li>';
  5. $items = $items . $profilelink;
  6. return $items;
  7. }
  8. add_filter( 'wp_list_pages', 'new_nav_menu_items' );
  9. add_filter( 'wp_nav_menu_items', 'new_nav_menu_items' );
  10.  
  11.  
  12. // Create Member Profile link with shortcode in pages and posts
  13.  
  14. function member_profile( $atts, $label = null ) {
  15. echo '' . $label . '';
  16. }
  17. add_shortcode('member_profile', 'member_profile');
  18.  
  19.  
  20.  
  21. Next, add the following to your style.css in order to float the new profile link to the right and add some font color and weight:
  22.  
  23.  
  24. li#my-profile.my-profile {
  25. float:right;
  26. }
  27.  
  28. li#my-profile.my-profile a {
  29. font-weight:bold;
  30. color:red;
  31. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.