• Resolved Jaelli

    (@jaelli)


    Client would like to have his first post title in red, second post title in blue, and alternate odd post titles in red, even in blue thereafter. Anyone have an idea how to make this easy for him to manage? He’s fairly clueless truthfully. Idiotproof would be ideal.

    Thanks for any ideas!

Viewing 5 replies - 1 through 5 (of 5 total)
  • you can add an extra css class to the post div or post title element (h3 ?);

    something along these lines:

    example for adding an alternating css class into the h3 tag:

    <h3 class="<?php echo (($wp_query->current_post%2 == 0) ? 'red-title' : 'blue-title'); ?>"><?php the_title(); ?></h3>

    Thread Starter Jaelli

    (@jaelli)

    Thanks, alchymyth. That looks like it should work. I’ve forgotten everything I knew about php and WP….

    Thread Starter Jaelli

    (@jaelli)

    Just to update: in order to get this to work, I had to add the php alchymyth provided into the <a> tagset, like this:

    <h2 class="entry-title"><a class="<?php echo (($wp_query->current_post%2 == 0) ? 'red-title' : 'blue-title'); ?>" href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>

    I also had to add and change things in the css of course.

    So client will be happy…. next thing of course is that he’ll want the single page title in the red and blue instead of black…. I might have to “just say no” at that point!

    At that point I would just say no and explain that it would become an accessibility issue as visitors wouldn’t be able to tell the difference between the colour of a post title and a link to that post.

    Thread Starter Jaelli

    (@jaelli)

    I believe you’re right Rab, and thanks for that thought.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Looking for a way to alternate post title colors’ is closed to new replies.