Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. function give_profile_name($atts){
  2. $user=wp_get_current_user();
  3. $name=$user->user_firstname .' '. $user->user_lastname ;
  4. return $name;
  5. }
  6.  
  7. add_shortcode('profile_name', 'give_profile_name');
  8.  
  9. add_filter( 'wp_nav_menu_objects', 'my_dynamic_menu_items' );
  10. function my_dynamic_menu_items( $menu_items ) {
  11. foreach ( $menu_items as $menu_item ) {
  12. if ( '#profile_name#' == $menu_item->title ) {
  13. global $shortcode_tags;
  14. if ( isset( $shortcode_tags['profile_name'] ) ) {
  15. // Or do_shortcode(), if you must.
  16. $menu_item->title = call_user_func( $shortcode_tags['profile_name'] );
  17. }
  18. }
  19. }
  20.  
  21. return $menu_items;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement