WordPress.org

Ready to get started?Download WordPress

Forums

How-to get post from some number (2 posts)

  1. linderox
    Member
    Posted 4 years ago #

    I have a featured first post on an example site
    I want to write the same index.php where the first is featured and another ones begins from second post on the main blog's page and from 1st on another. Which conditions and functions should I use for that purpose?

  2. nemci7v
    Member
    Posted 4 years ago #

    It involves query posts and multiple loops

    http://codex.wordpress.org/Template_Tags/query_posts

    so for example you would use query_posts('cat=3');

    to retrive the newest post from category 3

    also add &posts_per_page=1

    to display just 1 post

    example:

    <?php
    
    //The Query
    query_posts('cat=3&posts_per_page=1');
    
    //The Loop
    if ( have_posts() ) : while ( have_posts() ) : the_post();
     ..
    endwhile; else:
     ..
    endif;
    
    //Reset Query
    wp_reset_query();
    
    ?>

    For featured posts you can use a jquery slideshow

Topic Closed

This topic has been closed to new replies.

About this Topic