I have been coding a custom profile page for users in wordpress. its a hard coded file called "myprofile.php" I am unable to get the username to show up in the page title.. take a look : http://www.designzzz.com/user/ayazmalik/

k i tried a few filters to add title to this page but didn't helped me :( . lets say the username storing variable is $myusername . how can i do it.. im considering this title : <title>user_name</title>

Help is appreciated :) cheers

function my_doc_title($title, $separator){
  if(is_author()) // <- replace this with your custom page; maybe is_page_template('myprofile.php') ?
   $title = get_the_author_meta('display_name', get_query_var('author')).$separator.get_bloginfo('name');
  return $title;
add_filter('wp_title', 'my_doc_title', 10, 2);


| improve this answer | |
  • k i got it and i have tried somethign similar before but the problem is this time this myprofile.php isnt in the theme folder , its in the public_html/myprofile.php ... so what would u suggest me puting to replace is_author() ? – Ayaz Malik Jan 13 '11 at 3:11
  • does your page use the WP app? do $_SERVER['REQUEST_URI'] echo and see what you get – onetrickpony Jan 13 '11 at 3:15
  • hmm. i am a new php coder and coded it custom.. i get this : '/user/Tayyab/' on Tayyab's (user) profile .. You can run this to see designzzz.com/user/Tayyab – Ayaz Malik Jan 13 '11 at 3:20
  • you could use if(str_pos($_SERVER['REQUEST_URI'], '/user/') !== false) instead of is_author, but you should really find another way to create custom pages like this. You could have just customized the author archive page... – onetrickpony Jan 13 '11 at 3:26
  • hmm i see. my bad i guess first time customizing wordpress. . and thsi would be different from author page. i mean i am making a user base. where user have their custom account page, profiles, news submission page etc. if you can suggest me some place to read or anything i can find helpful to move it in the right direction i would be thankful :) . going to try what u suggest now. – Ayaz Malik Jan 13 '11 at 3:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.