Featured Posts filter problem on front page
-
I need to create a ‘featured posts’ section on the front page of a site I’m working on.
Simply, if a post is written by one author specifically, I need it to display that person’s name and avatar along with the permalink and the post date. However, if it’s written by another author (a psedu-admin account they’ll use for posting general info not attributed to any one author), I need it NOT to display a the name and avatar and simply render the permalink and the post date.
As I’m no PHP guru and is_author only render’s in the archives page, is there a way to do this in the loop? Code is below (‘xx’ represents authors nicename):
<?php if (is_author( 'xx' )) { ?> <h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a><br></h3> <small><?php echo get_the_date('F j, Y'); ?></small><br><br> <?php } else { ?> <div style="float:right; padding:0px 10px;"><?php echo get_avatar( get_the_author_email(), '40' ); ?></div> <h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a><br></h3> <small>by <?php the_author(); ?> | <?php echo get_the_date('F j, Y'); ?></small><br><br> <?php } ?> <?php endwhile; ?>
Also, am I doing something wrong here, other than the is_author reference?? The code works perfectly now but render the html for the ‘else’ statement.
- The topic ‘Featured Posts filter problem on front page’ is closed to new replies.