WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Only listing a few post titles in a catagory..? (8 posts)

  1. sithicus
    Member
    Posted 8 years ago #

    http://www.amypaturel.net/articles/

      <?php
      $posts = get_posts('category=2');
      foreach($posts as $post) :
      ?>

    • "><?php the_title(); ?>
    • <?php endforeach; ?>

    There are over 20 posts in this catagory why is it not listening them all?

  2. Samuel B
    moderator
    Posted 8 years ago #

    "><?php the_title(); ?>
    This line is correct?

  3. moshu
    Member
    Posted 8 years ago #

    It's just because people never learn how to post code ;)

    it is supposed to be
    <li><a>"><?php the_title(); ?></a></li>

    Edit. Though it doesn't make sense even in this way.

  4. sithicus
    Member
    Posted 8 years ago #

    <div class="cat-title">food & nutrition:</div>
    <ul>
    <?php $posts = get_posts('category=2');
    foreach($posts as $post) : ?>
    <li><a href="<?php the_permalink(); ?>">
    <?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>

  5. sithicus
    Member
    Posted 8 years ago #

    I hope that helps.. when posting code.. do I have to put each line between the ` ?

  6. moshu
    Member
    Posted 8 years ago #

    No, just don't have a blank line in the code - blank lines break the effect of the backticks.

  7. sithicus
    Member
    Posted 8 years ago #

    Yet no thoughts on how to get this code to list more then 5 results... ?

  8. moshu
    Member
    Posted 8 years ago #

    MEanwhile you were waiting here for an answer you could read as well the codex: Template_Tags/get_posts.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags