page template show posts (3 posts)

  1. razzera
    Posted 2 years ago #

    i have this little bit of code that get's all my current posts and display them on a page. I was wondering how i insteed of showing all posts in total show all post from a certain category. Anyone that can help me please?

    Template Name: All posts
    $debut = 0; //The first article to be displayed
    <?php while(have_posts()) : the_post(); ?>
    <h2><?php the_title(); ?></h2>
    $myposts = get_posts('numberposts=-1&offset=$debut');
    foreach($myposts as $post) :
    <li><?php the_time('d/m/y') ?>: <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    <?php endwhile; ?>
  2. jamesg40
    Posted 2 years ago #

  3. Vichet Sen
    Posted 2 years ago #

    To do show posts from a specific category, you need to modify your while loop and WordPress has WP_Query to help you do like that.

    Here is the link: http://codex.wordpress.org/Class_Reference/WP_Query

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.