WordPress.org

Ready to get started?Download WordPress

Forums

custom loop help (3 posts)

  1. raptrex
    Member
    Posted 6 years ago #

    for my custom loop, the posts are in categories with the first post being an excerpt and the previous 5 posts of that category is just the title of that post
    ex:

    Cat (category)
    Latest post 6 in Cat
    bla bla bla bla
    Previous post 5 in Cat
    Previous post 4 in Cat
    Previous post 3 in Cat
    Previous post 2 in Cat
    Previous post 1 in Cat

    Dog (category)
    Latest post 6 in Dog
    bla bla alblabl lal
    Previous post 5 in Dog
    ...

    so how would i do this?

  2. raptrex
    Member
    Posted 6 years ago #

    ok i dont think you can make it do each category in sections automatically so i think i have to do it like this:
    <?php $posts = get_posts( "category=3&numberposts=3" ); ?>

    but how would i make it where the latest post in that category is an excerpt then the rest in that cat is a list

    then do it again for the rest of the categories

  3. raptrex
    Member
    Posted 6 years ago #

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

    <div class="post" id="modernScience">
    <h2>Modern Science</h2>
    <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    <div class="pleft">
    <h3 class="entry-title">" title="<?php printf(__('Permalink to %s'), wp_specialchars(get_the_title(), 1)) ?>" rel="bookmark"><?php the_title() ?></h3>
    <div class="entry-content">
    <?php the_content("<span class=\"continue\">" . __('Continue reading','') . " '" . the_title('', '', false) . "'</span>"); ?>
    </div>
    </div>
    <div class="pright">

    </div>
    <?php endforeach; ?>

    </div>

    <?php endif; ?>

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

    <div class="post" id="lifestyle">
    <h2>Lifestyle</h2>

    </div>
    <?php endforeach; ?>

    </div>

    <?php endif; ?>

    so this is what i have so far
    but how do i make the latest post be in "pleft" and the next 5 in "pright"?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.