jay.weeks
Member
Posted 2 years ago #
i want to link to the latest post for four different categories.
can't seem to get it to work
<?php
$nc = get_cat_id('news');
query_posts('cat=$nc');
?>
<?php
$latestNewsPost = get_posts('numberposts=1&category=$nc');
$latestNewsPostID = $wp_query->$latestNewsPost->ID;
?>
<div class="home-header" id="news-head"><a title="news" href="<?php echo get_permalink($latestNewsPostID); ?> ">news</a></div>
This is what I use to show the permalink of the latest post in "my_category", and in one instance, I use several of these loops on one page to show the latest post in three different categories. Seems like each new query doesn't conflict with any of the others.
<?php $my_query = new WP_Query('category_name=my_category&showposts=1'); ?><?php while ($my_query->have_posts()) : $my_query->the_post(); ?><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a><?php endwhile; ?>
jay.weeks
Member
Posted 2 years ago #
cool, seems to be working