get_the_author_meta conditional display
-
I’ve run into a bit of a snag with a theme I’m developing. I’ve created a custom user profile field called “occupation” (using the tutorial located on Justin Tadlock’s blog), when the user comments on a post I want to display the following specific information about the user commenting:
If the person’s occupation is set to “alpha” display:
I am an alpha, my job consists of A, B & C.If the person’s occupation is set to “beta” display:
I am a beta, my job consists of D, E & F.If the person’s occupation is set to “gamma” display:
I am a gamma, my job consists of G, H & I.If the person is none of these, display nothing.
I can get the users occupation to display by simply using:
<?php get_the_author_meta('occupation'); ?>
If I try to create a conditional statement, nothing shows up. Here’s what I tried:
<?php $occupation = get_the_author_meta('occupation'); if($occupation == 'alpha') { ?> I am an alpha, my job consists of A, B & C <?php } elseif($occupation == 'beta') { ?> I am a beta, my job consists of D, E & F <?php } elseif($occupation == 'gamma') { ?> I am a gamma, my job consists of G, H & I <?php } else { ?> <?php } ?>
The only way I can get anything to display is by changing
if($occupation !== 'value')
but by doing that I end up with all of the values showing up for every occupation type so after every comment it spits out: I am an alpha… I am a beta… I a gamma… one after the other.Obviously there has to be a better way of doing this. Any suggestions and help would be greatly appreciated!
- The topic ‘get_the_author_meta conditional display’ is closed to new replies.