Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 0 down vote accepted
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);

(functions.php)

share|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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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