While creating a blog using wordpress, you might require this quick tips that are very important and used quite often.
Grab Category name
< ?php
$category = get_the_category();
echo $category[0]->cat_name;
?>
Get Featured post
< ?php query_posts('cat=3&showposts=1'); ?>
< ?php while (have_posts()) : the_post(); ?>
< ?php the_excerpt('Read the rest of this entry »'); ?>
< ?php endwhile; ?>
You can change the number of post you want to show by changing showposts=any number. The example above shows post from category 3. You can exclude the same category by using cat=-3.
Show Recent Post using new WP_Query()
< ?php $recent = new WP_Query("page_id=2&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
< ?php the_excerpt('Read the rest of this entry »'); ?>
< ?php endwhile; ?>
Show posts in reverse order
In your index.php file, look for this bit of code: < ?php if(have_posts()) : ?>< ?php while(have_posts()) : the_post(); ?> Right before that line, add this code: < ?php query_posts($query_string . “&order=ASC”) ?>