Forums

Want posts in category on main page but not with the rest. (4 posts)

  1. betawaffles
    Member
    Posted 4 years ago #

    I am trying to get posts in a category to appear on the main page but in a div on its own, not with the rest of the posts. Any idea on how to accomplish this, Either using php or a plugin? The category number is 3.

  2. betawaffles
    Member
    Posted 4 years ago #

    To answer my own post, this does the trick:

    <?php $posts = get_posts( "category=6&numberposts=10" ); ?>
    <?php if( $posts ) : ?>

    <div class="post" id="post-<?php the_ID(); ?>">

    <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>

    <?php echo wptexturize($post->post_content); ?>

    <?php endforeach; ?>
    </div>
    <?php endif; ?>

    </div>
    <?php get_footer(); ?>

  3. betawaffles
    Member
    Posted 4 years ago #

    Oops ignore that last </div> and <?php get_footer(); ?>.

  4. betawaffles
    Member
    Posted 4 years ago #

    The post title will not appear right actually, it displays the most recent post title in general.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.