is_author – Myth? or am I misusing the function?
-
I’m trying to avoid writing specific queries in my main page. Hence I’m trying use built in functions for WordPress to create the criteria for specific forms.
My webpage will consist of two writers (Author #2 and Author #3). There is no Author #1. Each having different border colors, possible translucent bg pictures.
However, I cannot get my wordpress 2.2 to recognise the function is_author.
<?php if (have_posts()) : ?> /* Start loop /* <?php if (!in_category('3')) continue; ?> /*Remove all other categories /* <?php query_posts("showposts=2"); ?> /*Remove all but last 2 posts/* <?php while (have_posts()) : the_post(); ?> /* Continue loop /* <?php if (is_author('2')) { ?> /*Start if for user specific post layout /* <h1> /* -Title- -H3 is author #2 specific- /* </h1> //* My php/html code specific for author #2 <!-- <?php trackback_rdf(); ?> --> <?php } else /* add else statement for other author /* { ?> <h3> /* -Title- -H1 is author #3 specific- /* </h3> //* My php/html code specific for author #3 <!-- <?php trackback_rdf(); ?> --> <?php } ?> /*end else statement/* <?php endwhile; else: ?> /*end while/* <?php _e('This user has yet to respond'); ?> <?php endif; ?> /*end if/*My result is that it:
1. Correctly removes unwanted categories.
2. Correctly removes all but last 2 posts.
3. Incorrectly shows neither of the <h1> or <h2> header settings in either of the if or else statements (which I didn’t know it was possible to EVER have an option A and option B in an if/else statement and the code choose option C).I hope I haven’t provided too much code, but I believe it may be:
1. I’m misunderstanding the functionality of is_author.
2. is_author is not in 2.2 or has been removed in 2.2.
3. An ordering issue in which I’ve simply placed code incorrectly in the loop.
4. I’m just too lazy to write a query and wordpress doesn’t create a functional variable for the value of the post’s author.
The topic ‘is_author – Myth? or am I misusing the function?’ is closed to new replies.