WordPress.org

Ready to get started?Download WordPress

Forums

removing <p> tag from the_excerpt (8 posts)

  1. kappaluppa
    Member
    Posted 7 years ago #

    This is the page I'm working on: http://asplashofcoloronline.com/category/tips/

    It seems that the the_excerpt tag adds <p> </p> in the excerpt. I want to take that out. And I want to add an indent. I've tried doing it with css, but to no avail.

    So I'm looking for where the function is and maybe I can adjust it there.

    BTW,
    here is the css I tried. Maybe I goofed that up:

    .moveupandover {
    margin: -15px 0 0 15px;
    }

    <span class="moveupandover"><?php the_excerpt(); ?></span>

    ========
    thanks,
    K

  2. whooami
    Member
    Posted 7 years ago #

    <?php
    /*
    Plugin Name: No Excerpt-P
    Description: Removes the paragraph tags from the output returned by the_excerpt() function
    Version: 1.0
    Author: Amit Gupta
    Author URI: http://blog.igeek.info/
    */
    remove_filter('the_excerpt', 'wpautop');
    ?>

    Just copy all that into a text file, rename it blah.php and upload it to your plugins folder. Activate it, and youre done.

  3. kappaluppa
    Member
    Posted 7 years ago #

    FANTASTIC! Works like a charm!
    thanks for the quick response!
    K

  4. kappaluppa
    Member
    Posted 7 years ago #

    Another question...
    how to change the [...] to "Read More..." or some such?

  5. auschick
    Member
    Posted 6 years ago #

    Sweet! I had the same problem and that fixed it :-).

    @Kappuluppa: one thing you can do is go back through your posts and fill in the "optional excerpt" bit at the bottom of the write post admin panel. WordPress will use this excerpt rather than the generated one.

    This is what my template looks like:
    <?php the_excerpt(); ?><span class="readmore"><a href="<?php the_permalink ?>">Read This</a></span>

  6. natalie
    Member
    Posted 6 years ago #

    NOTE: You don't actually need to make a plugin for this. It will work simply by adding the code anywhere on your page... <?php remove_filter('the_excerpt', 'wpautop'); ?>

  7. Kilroy
    Member
    Posted 6 years ago #

    The code can also be placed in the functions.php file.

    Thanks for this solution anyway, it took me a while to find it.

  8. krembo99
    Member
    Posted 6 years ago #

    Thanks for that line of code !
    I got close to crazy with trying to validate my tamplate...

Topic Closed

This topic has been closed to new replies.

About this Topic