WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Cutting the content... (6 posts)

  1. evodex
    Member
    Posted 6 years ago #

    Hi everyone!

    I am trying to cut the_content after the first paragraph (e.g. after </p>) but I've had no luck for several hours and searching for this difficult so I'm turning to you guys.

    I realize I will have to use some form you string cut (e.g. strstr() < but this one only allows me to cut out everything before </p> unless I run PHP6 which is not possible)..

    So, what I want is something that cuts like this.

    The content is: <p> Hi everyone! </p> <p> I don't want this to print </p>
    And I want this to print: <p> Hi everyone! </p>

    I hope this makes sense.

    Kind Regards,
    Jan-Erik

  2. fitztrev
    Member
    Posted 6 years ago #

    explode maybe? This is quick and gets the job done.

    <?php
    $blah = exlode( '</p>', get_the_content(), 2 )
    echo $blah[0] . '</p>';
    ?>
  3. evodex
    Member
    Posted 6 years ago #

    Thanks a bunch, works like a charm! :)

    I have another question though, is there anyway to strip graphics from get_the_content (e.g. so no images are printed)?

    Thanks,
    Jan-Erik

  4. fitztrev
    Member
    Posted 6 years ago #

    Yes, you can use strip_tags().

  5. talgalili
    Member
    Posted 5 years ago #

    Hi there.

    To continue evodex first question - is there a way to only show the first X words of a post (in the loop, in the home page) ?
    what php code might do that ?

    (since none of the plugins that offer that work in WP 2.6.5)

    Thanks

  6. talgalili
    Member
    Posted 5 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic