• TMF

    (@tanialazib)


    Hi,
    When I use:
    <?php the_excerpt(‘Read the rest’); ?><br class=”clearfloat”/>
    <?php } else { ?>
    <?php the_content(‘Read the rest’); ?>
    <?php } ?>

    I get the whole article. It doesn’t use excerpt.

    When I use:
    <?php the_excerpt(‘Read the rest’); ?><br class=”clearfloat”/>
    <?php } ?>

    I get just get the title even though I entered the exerpt into the post box.

    And when I use:

    <?php the_excerpt(‘Read the rest’); ?><br class=”clearfloat”/>
    <?php } else { ?>
    <?php the_excerpt(‘Read the rest’); ?><br class=”clearfloat”/>
    <?php } ?>

    It all works.

    Is that supposed to be the case or is something gong wrong with my index.php page?

    THanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi, i’m not sure about this code:
    <?php the_excerpt('Read the rest'); ?><br class="clearfloat"/>
    I don’t think I have entered anything in the parentheses before. The “Read the rest” part might be screwing it up? Have you tried it without it?

    There is a filter method here: https://codex.www.ads-software.com/Function_Reference/the_excerpt
    I’ve used that before, but not the way your doing it. I may be completely wrong so take it with a pinch of salt ; )

    Dan

    Thread Starter TMF

    (@tanialazib)

    <?php the_excerpt(); ?>

    Is also not working.

    Moderator keesiemeijer

    (@keesiemeijer)

    What is the condition part of the if(condition){...} else {...}

    Could you post a bit more of your code? Like the whole loop or query your using?

    I was wondering that too keesiemeijer, wordpress will find and excerpt anyway, you don’t have to write it in the excerpt box. It generates one by taking the first so many words from the content.

    You should have something like

    <?php the_title(); ?>
    <?php the_excerpt(); ?>

    or

    <?php the_title(); ?>
    <?php the_content(); ?>

    Thread Starter TMF

    (@tanialazib)

    This is the whole page:

    <?php get_header(); ?>
    <?php if(is_home() && !is_paged()): ?>
    <?php include (TEMPLATEPATH . '/featured.php'); ?>
    <?php endif;?>
    
    <!--main content area  -->
    
    <?php include (TEMPLATEPATH . '/colmnWrapper.php'); ?>
    <div id="center">
      <div class="content">
    
                      <h1><a href="<?php bloginfo('rss2_url'); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/rss.gif" alt="Main Content RSS Feed" title="Main Content RSS Feed" style="float:right;margin: 2px 0 0 5px;" /></a>Other Stuff</h1>
                <?php query_posts('posts_per_page=10'); ?>
    
    <?php if (have_posts()) : while (have_posts()) : the_post();
    if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
    
                    <div class="post" id="post-<?php the_ID(); ?>">
    
                        <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?> &raquo;</a></h2>
    
                        <p class="postinfo">By <?php the_author_posts_link(); ?> on <?php the_time('M j, Y') ?> in <?php the_category(', ') ?> | <?php comments_popup_link('0 Comments', '1 Comment', '% Comments'); ?><?php edit_post_link('Edit', ' | ', ''); ?></p>
    
                            <div class="entry">
          <!--
            Display a thumbnail for the article. Get this from the custom
            value 'thumbpic'.
          -->
             <?php $thumb = get_post_meta($post->ID, "thumbpic", true); if ($thumb != "") { ?>
                    <img src="<?php $values = get_post_custom_values("thumbpic"); echo $values[0]; ?>" alt="<?php the_title(); ?>" class="thumbpic" />
    
                     <?php the_excerpt(); ?><br class="clearfloat"/>
            <?php } else { ?>
    
                    <?php /* the_content*/ the_excerpt();?><br class="clearfloat"/>
            <?php } ?>
    
        </div>
    
    </div>
    
        <?php endwhile; endif; ?>
        <div class="navigation">
          <div class="alignleft">
            <?php next_posts_link('&laquo; Previous Entries') ?>
          </div>
          <div class="alignright">
            <?php previous_posts_link('Next Entries &raquo;') ?>
          </div>
        </div>
    
        <!-- closes center content  -->
    
      </div>
    </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Looks like the conditional statement is to do with that thumbnail….if its there you echo the_excerpt(); if its not you use the_content(); (well, if its not commented out)

    Is the thumbnail showing up ok?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘the_excerpt on index.php not working’ is closed to new replies.