<ul id="post-list">
<?php
global $post,$wp_query;
$current_id = $wp_query->get_queried_object_id();
$args = array('category_name'=>company,'numberposts' => -1);
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<li<?php if ($current_id == $post->ID) echo ' class="current"'; ?>>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>
Home / php / website / wordpress / How can I have a class of 'current' be displayed for the current post
Subscribe to:
Post Comments (Atom)
Post a Comment
Post a Comment