Pages

Wednesday, October 26, 2011

Wordpress: Getting posts by Category Name

The below code retrieves all posts under a certain Category Name in Wordpress:

<?php
    // retrieve posts under the category banners
    query_posts( 'category_name=banners' );

    // the Loop
    while (have_posts()) : the_post();
        the_content( 'Read the full post »' );
    endwhile;
 ?>

No comments :

Post a Comment