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?

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

  • 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. Jan 20 '12 at 18: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.