• Resolved therealhopeful

    (@therealhopeful)


    According to the codex documentation the_excerpt() API will automatically strip HTML tags under certain conditions. However, I cannot seem to get it to work. Here is my code:

    <?php while (have_posts()) : the_post(); ?>
            <h1><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php echo strip_tags( the_excerpt() ); ?>" alt="<?php echo strip_tags( the_excerpt() ); ?>"><?php the_title(); ?></a></h1>
          <?php endwhile; ?>

    If you go to this link and hover your mouse over the headings, you will see what I am talking about.

    How do I get the_excerpt to strip the HTML tags?

    Thanks! ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • Doesn’t that work if you are called the_excerpt() and not using the conditional of it while called the_post(). Anyone?

    Trent

    Thread Starter therealhopeful

    (@therealhopeful)

    Thanks for the suggestion, Trent, but it’s no-go. I tried both of the following bits of code, and they ended up generating an endless loop:

    <?php while (have_posts()) : ?>
            <p><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php echo strip_tags( the_excerpt() ); ?>" alt="<?php echo strip_tags( the_excerpt() ); ?>"><?php the_title(); ?></a></p>
          <?php endwhile; ?>
    <?php while (have_posts()) : the_excerpt(); ?>
            <p><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php echo strip_tags( the_excerpt() ); ?>" alt="<?php echo strip_tags( the_excerpt() ); ?>"><?php the_title(); ?></a></p>
          <?php endwhile; ?>

    Any other thoughts? ??

    Thread Starter therealhopeful

    (@therealhopeful)

    Issue resolved! ??

    There’s a hidden API that does the job:

    get_the_excerpt()

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘the_excerpt()’ is closed to new replies.