• Hey there,

    I’ve been looking all over the place trying to figure out the best way to do this… I’m just trying to have each post being set to a different text colour depending on which author published the post. Can it be done?

    Thanks yo!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Can it be done?

    yes it can. you will need to grab the author name — you can do that using the template tag, the_author, and style the text accordingly. I’ll use the default theme as an example and show you how that might be done.

    Inside index.php the loop has this:

    <div class="entry">

    that means every bit of post content is wrapped in a <div> with the class “entry”.

    You can change that like so:

    <div class="entry-<?php the_author(); ?>">

    Using the above, the content of a post by me would be wrapped in:
    <div class=entry-whoo"></div>

    and the content of a post by you would be wrapped in:
    <div class=entry-misterpeterman"></div>

    Once thats done, you just edit your stylesheet accordingly to produce the diff. text colors.

    The above example is specific to the content of the post, not the post title, not the “written by” bit, the permalink, etc.. Take a look at the default theme’s index.php to see what I mean.

    Thread Starter misterpeterman

    (@misterpeterman)

    Thanks!

    anyone offer any help as to how to do this with the sandbox template? the index.php <div class etc…> looks very different from the aforementioned

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Different coloured text for different authors’ is closed to new replies.