how to display posts from a specific categories on a Page

Discussion in 'WordPress' started by leilal, Nov 9, 2010.

  1. #1
    Hi,

    I am having a lot of trouble displaying posts from a specific category on a page. I want to make a blog page, but only have posts from the blog category to show.

    I have used this code, which shows the category titles but not the content:

    <?php
    global $post;
    $myposts = get_posts('numberposts=5&offset=1&category=13');
    foreach($myposts as $post) :
    ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>

    Does anyone know how I can adapt/add to this code so the full post content shoes please?

    I have asked this question before and people have sent me links about "the loop" but I didn't really understand it :S

    Thank you
     
    leilal, Nov 9, 2010 IP
  2. s_ruben

    s_ruben Active Member

    Messages:
    735
    Likes Received:
    26
    Best Answers:
    1
    Trophy Points:
    78
    #2
    Try this code:

    
    <?php
    global $post;
    $myposts = get_posts('numberposts=5&offset=1&category=13');
    foreach($myposts as $post) :
    ?>
    <li>
    <a href="<?php echo(get_permalink($post->ID)); ?>"><?php echo($post->post_title); ?></a>
    <p><?php echo($post->post_content); ?></p>
    </li>
    <?php endforeach; ?>
    
    PHP:
     
    s_ruben, Nov 9, 2010 IP
  3. leilal

    leilal Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you s_ruben, that worked! very graterful
     
    leilal, Nov 9, 2010 IP