0815

Du musst dich anmelden um Beiträge und Themen zu erstellen. Einloggen · Registrieren

Custom CSS Styles for Recent Posts

Use some custom CSS styles to highlight your recent posts. To do this, replace your existing loop with the following:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

	$currentdate = date('Y-m-d',mktime(0,0,0,date('m'),date('d'),date('Y')));
	$postdate = get_the_time('Y-m-d');
	if ($postdate == $currentdate) {

		echo '<div class="post new">';

	} else {

		echo '<div class="post">';

	} ?>

		<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
	</div>

<?php endwhile; endif; ?>

This new loop will check the date of each post and include a CSS class of “new” to any post published within the previous 24-hour time period. Once the new post class is included, you may style it with some custom CSS such as the following:

.post{
	/* styles for all posts */
	}
.post.new {
	/* styles for new posts */
	}

Source: Fred jaillet [via] WPRecipes.com




0