SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Jun 2006
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    excerpt of posts on homepage

    HI folks,

    Can someone please tell me how I can display the content of my post up until the more tag, displayed on the homepage of my site?

    I've read up on the loop and the excerpt, but I'm really struggling to understand how it works. Can someone please give me some sample code?

    If I know the post id of my post, what do i need to add to home.php?

    I cant even get any content to display using this code:

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php the_content(); ?>
    <?php endwhile; ?>
    <?php endif; ?>

    can someone please help? I'm getting very desperate

    Many thanks in advance

  2. #2
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Something like this should work
    PHP Code:
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2
    <div class="entry">
    <?php the_exerpt(); ?>
    </div><!-- end entry -->
    </div><!-- end post -->
    <?php endwhile; ?>
    <?php 
    else : ?>
    <?php 
    endif; ?>

  3. #3
    Mazel tov! bronze trophy kohoutek's Avatar
    Join Date
    Aug 2004
    Location
    Hamburg, Germany
    Posts
    4,248
    Mentioned
    30 Post(s)
    Tagged
    0 Thread(s)
    Do you have multiple loops running on index.php?

    If so, use a custom loop, e.g. something like this:

    PHP Code:
    <?php
    $loop 
    = new WP_Query$args );
    while ( 
    $loop->have_posts() ) : $loop->the_post();
    ?>

    <h2><?php the_title(); ?></h2>
    <?php the_excerpt(); ?> // only works if you use the custom excerpt field

    <?php endwhile; ?>
    Maleika E. A. | Rockatee | Twitter | Dribbble




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •