WordPress.org

Ready to get started?Download WordPress

Forums

Displaying the 5 latest posts by: (12 posts)

  1. Swooper
    Member
    Posted 9 years ago #

    hello, why does this:

    [code] <?php
    $posts = get_posts('numberposts=5');
    foreach ($posts as $post) :
    ?>
    <h4>" rel="bookmark"><?php the_title(); ?></h4>
    <div class="post"><?php the_excerpt(); ?></div>
    <p class="custom"><?php the_time('d. F Y ') ?> abgelegt in <?php the_category(', ') ?> | <?php edit_post_link('Edit','',''); ?>
    <?php
    endforeach;
    ?>[/code]

    only function with the_excerpt? By trying to display the_content nothing could be seen..

  2. Joshua Sigar
    Member
    Posted 9 years ago #

  3. Swooper
    Member
    Posted 9 years ago #

    doesn´t quiet do, what was supposed to..

    I just need a independent site where the five latest entries are displayed like <?php the_content('Go on »'); ?>

    possible at all?

  4. Kafkaesqui

    Posted 9 years ago #

    After:

    foreach ($posts as $post) :

    add

    start_wp();

    or in WordPress 1.5+, you can use:

    setup_postdata($post);

    Whichever one you go with, it's sort of required for the_content().

  5. Swooper
    Member
    Posted 9 years ago #

    yes, you´re right now I can use the content but only the whole content something like

    [code]<?php the_content('Go on »'); ?>[/code]

    doesn´t work at all :/

  6. Joshua Sigar
    Member
    Posted 9 years ago #

    1. now I can use the content but only the whole content
    What does whole content refer to? What are other types of content?

    2. something like

    [code]<?php the_content('Go on »'); ?>[/code]

    doesn´t work at all :/
    What does work?

    3. Why the link I gave you above does not do what you want?

  7. bacon
    Member
    Posted 9 years ago #

    I'm having this problem too, I want the homepage to display specifics, eg the last 5 posts in category1, and the last 6 posts from category2. [code]<?php the_content('Read the rest of this entry...»'); ?>[/code] works, but it displays the entire post, disregarding where <!--more--> should kick in.

    I had an idea for index.php - [code] if (URLrequestedVariable(?) == $_SERVER['DOCUMENT_ROOT']) { special index by category case } else { standard if (have_posts()) : loop. [/code]

  8. Joshua Sigar
    Member
    Posted 9 years ago #

    http://codex.wordpress.org/The_Loop#Multiple_Loops_Version_1
    2nd example

    I just verified myself with WP 1.5.1.2 that more tag is applied.

    Post your code here. http://pastebin.com

  9. Swooper
    Member
    Posted 9 years ago #

    @ kafkaesqui

    [code] <?php
    $posts = get_posts('numberposts=5');
    foreach ($posts as $post) : setup_postdata($post);
    ?>
    <h4>" rel="bookmark"><?php the_title(); ?></h4>
    <div class="post"><?php the_content('More »'); ?></div>
    <p class="custom"><?php the_time('d. F Y ') ?> abgelegt in <?php the_category(', ') ?> | <?php edit_post_link('Edit','',''); ?>
    <?php
    endforeach;
    ?>[/code]

    doens´t work :(

    @ alphaoide

    I tried your suggestion, but didn´t get it to work, could you post a working example?

  10. Swooper
    Member
    Posted 9 years ago #

    [code][code] <?php
    $posts = get_posts('numberposts=5');
    foreach ($posts as $post) : setup_postdata($post);
    ?>
    <h4>" rel="bookmark"><?php the_title(); ?></h4>
    <div class="post"><?php the_content(); ?></div>
    <p class="custom"><?php the_time('d. F Y ') ?> abgelegt in <?php the_category(', ') ?> | <?php edit_post_link('Edit','',''); ?>
    <?php
    endforeach;
    ?>[/code]

    works fine

    [code][code] <?php
    $posts = get_posts('numberposts=5');
    foreach ($posts as $post) : setup_postdata($post);
    ?>
    <h4>" rel="bookmark"><?php the_title(); ?></h4>
    <div class="post"><?php the_content('More »'); ?></div>
    <p class="custom"><?php the_time('d. F Y ') ?> abgelegt in <?php the_category(', ') ?> | <?php edit_post_link('Edit','',''); ?>
    <?php
    endforeach;
    ?>[/code]

    as I need it with the 'More'-option doesn´t..

  11. Mark (podz)
    Support Maven
    Posted 9 years ago #

    Do not post code here.

    Read the posts before yours please.

  12. Kafkaesqui

    Posted 9 years ago #

    The "More »" example works for me (that is, as one would expect it to--with the more link appearing with posts that use the more quicktag).

    What version of WP are you running?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags