• Resolved crowd

    (@crowd)


    I would like to place the list of my recent posts on one of my static pages. It should go after the main text and show excerpts of the 5 latest posts.
    Could anyone help me with that?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter crowd

    (@crowd)

    Esmi, your help is appreciated, but my terminal dullness keeps me from understanding any of your answers. If i were a php guru, i would probably save your time by never posting questions like above.

    So, let me show what i really have trouble with:
    I obviously need to put this multiple loop code somewhere into my index.php or content-page.php (cause it’s for the pages, right?)
    This code should read smth like:

    <?php if (it’s the 2nd paragraph of the needed page()) : ?>
    <?php while (it’s the 2nd paragraph of the needed page()) : it’s the 2nd paragraph of the needed page(); ?>
    <?php the_excerpt(); ?>
    <?php endwhile; ?>
    <?php endif; ?>

    That’s my best i can make out of it.
    I don’t know how to make it work, i truly have no idea how to make the excerpt appear in the right place. And i really know very little of php to make the right conclusions of the vague answers. My bad, but if i were any smarter, i would find the answer myself.

    And yes – i truly admire your knowledge and appreciate your time trying to help desperados like me.

    What theme are you using?

    Thread Starter crowd

    (@crowd)

    Im using the child of 2011

    You need to create a custom page template in your child theme and add the secondary loop code to this new template. Start by copying the code from the parent’s page.php template file, then add the secondary query to suit your needs. something like:

    <?php
    $args = array( 'numberposts' => 5 );
    $recentposts = get_posts( $args );
    if( $recentposts ) echo '<ul class="recent-posts">';
    foreach($recentposts as $post) : setup_postdata($post); ?>
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php endforeach;
    if( $recentposts ) echo '</ul>';?>

    should work.

    Thread Starter crowd

    (@crowd)

    Esmi, thanks a lot. That’s what i needed. Will do.

    Thread Starter crowd

    (@crowd)

    Esmi, thank you so much, it works like a charming charm!
    And be sure, i would never get any close to this myself.

    Glad I could help ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘List of post excerpts to the page’ is closed to new replies.