Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Well, I already answered this in another post, but here it is again:

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

    I should also mention that you need to change the category=1 to = the category ID number of your desire.

    I’d really like to know how to make the category ID generate automatically. As in, if you added this code to a specific page within a category, it would pull that category ID and display more posts related to that category. I’ve been trying to figure this out, but apparently my PHP is lacking.

    You actually don’t need a plugin for this as the WordPress Codex includes this feature.

    Just use the following code:

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

    If you don’t want it to post a digest, than use this code:

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

    I didn’t make this up, the smart dudes at WordPress and nerds from around the world did. I always suggest searching the WordPress documentation before relying on a plug in–those things are so annoying to update!

Viewing 3 replies - 1 through 3 (of 3 total)