WordPress.org

Ready to get started?Download WordPress

Forums

get_posts and <!--more--> problem (4 posts)

  1. jakemc
    Member
    Posted 8 years ago #

    Hi. I have the following code inserted in my sidebar. the_content works except that the full post is displayed rather than the text to the <!--more--> tag.

    Can anyone help me to sort this? Thanks in advance.
    <?php
    $posts = get_posts('numberposts=100&category=2');
    foreach($posts as $post) :
    setup_postdata( $post ); ?>
    <h2><?php the_title(); ?></h2>
    <?php the_content('more'); ?>
    <?php endforeach; ?>

  2. Samuel B
    moderator
    Posted 8 years ago #

    Try using
    the_excerpt
    instead of
    the_content

  3. jakemc
    Member
    Posted 8 years ago #

    Thanks samboll. That's good advice except that the_excerpt doesn't preserve any rich text formatting and I have no control about how much of the post is shown.

    Any suggestions as to how to get the_content to operate as it should?

  4. Samuel B
    moderator
    Posted 8 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic