• Resolved formica

    (@formica)


    Hi there

    In my single.php sidebar I’m using this code to bold the current menu item displayed as a list of category posts:

    <li<?php if ( $post->ID == $wp_query->post->ID ) { echo ' class="current"'; } else {} ?>>

    Works fine. Question is on my category.php page when I list my posts to use as a menu:

    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    <li<?php if ( $post->ID == $wp_query->post->ID ) { echo ' class="current"'; } else {} ?>>
    <a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>

    How do I bold up the first title? ie. to denote you’ve landed on the latest post in that cat. Currently they all print as bold. I’m guessing a counter of some sort?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Since you’re only looking to modify the first menu item, and you have them set up in an unordered list; you could use a counter or you could just use CSS2 without having to add any special classes to the item.

    The following CSS will bold the first item in the list and the rest of the list items will have standard formatting (assuming that the class of the unordered list is “category-list”):

    ul.category-list li:first-child {
    font-weight: bold;
    }

    This CSS is supported in IE7 and above; and is supported in all other browsers of which I am aware. If you need to support Internet Explorer 6, you may need a fallback.

    Thread Starter formica

    (@formica)

    Hi Curtis

    That worked perfectly! Thanks very much. I never knew that class existed.

    Fingers crossed ie6 disappears soon. But just in case anyone knows any other solutions, please let me know.

    Thanks again!

    Thread Starter formica

    (@formica)

    For the record found a way of outputting the result using a counter in php, thanks all:

    http://wordpress.org/support/topic/bold-up-first-result-of-loop

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Bold first post title in category’ is closed to new replies.