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've recently added a new field into the User Profile section of my blog So that I may define the gender of the user.

On the author bio section I have this code:

$authorgender = strtolower(get_the_author_meta('gender'));

if ($authorgender = "male") {
    $genderoutput = "his";
} else {
    $genderoutput = "her";
    };'

And the place i'm using it is:

  <p><a href="<?php the_author_meta('url'); ?>" target="_blank" title="<?php the_author(); ?>'s website (new window)">Check out <?php echo $genderoutput; ?> website</a>

I have two users, One myself which I changed the gender to 'Male' and one a random woman called sally-louise-fredericke-swann and her gender was set to 'Female'.

However, the $genderoutput generates 'his' for both users. Not happy :/

Any Ideas?

share|improve this question

1 Answer 1

if ($authorgender = "male") {

Needs to be

if ($authorgender == "male") {

== is a comparison operator http://www.php.net/manual/en/language.operators.comparison.php

= assigns the value to the variable http://www.php.net/manual/en/language.variables.basics.php

share|improve this answer
    
Holy crap, im so tired and thank you very much! more caffeine needed me thinks - never a good idea to try and code after a 10 hour shift in a restaurant. –  Mark Petherbridge Jan 20 '12 at 18: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.