Strip Tags off Excerpt, reformat with CSS (2 posts)

  1. lexipixel
    Posted 6 years ago #

    I have a website where I use another content management system for the majority of the site, but have WordPress setup also. I added an SSI tag into the home page of the site:

    <!--#include virtual="/wp-last-5.php" -->

    which causes the file: wp-last-5.php to be parsed and the last (5) post's titles, date-stamps and excerpts to be inserted into the HTML page, (and use the CSS styling of the rest of the site).

    The file wp-last-5.php contains:

    <?php require('/path/to/wp-blog-header.php'); ?>
    <?php query_posts('showposts=5'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <div style="margin: 4px 0; border-style: solid; border-color: c4c4c4; border-width: 0 0 1px 0;">
    <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a><br />
    <small><?php the_time('F jS, Y') ?> by <?php the_author() ?></small>
    <?php the_excerpt(); ?>
    <?php endwhile;?>

    ...and works fine.

    The problem(s):

    1). I can not get strip_tags(), str_replace() or other php string functions to strip the <p> and </p> tags out of the excerpt.

    2). The excerpts end with [...] but this is not clickable (for the implied "Read More..."). I'd like to end each excerpt with a link to the post.

    Is there a reason:

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

    will not work (in the loop)?

  2. iLm@N
    Posted 6 years ago #

    have you try this solution?

    based on that discussion, the correct one is
    <?php strip_tags(get_the_excerpt()); ?>

    is it resolve your problem?

Topic Closed

This topic has been closed to new replies.

About this Topic