Support » Plugins » Hacks » How to trim post

  • Dear friend
    Please help me to trim a post (about 200word) ,
    this code for post :
    <?php echo $post->post_content; ?>

    Please help me
    “Vietnam has exerted itself to be a favorite destination of more and more tourists. There’s a Hanoi elegant with friendly people, a Sapa with colourful-dressed minorities, a Halong Bay with amazing caves listed on UNESCO World Heritage. There’s a Hue romantic with palace and rain, a tranquil Hoi An where you can have clothes made in one day, a Danang dynamic by Han river. There’s a Nha Trang with best bays of the world, a Saigon busy and modern like Newyork, a Mekong-delta with fascinating floating market……”

Viewing 1 replies (of 1 total)
  • Well, somehow (i’m not play with this – just for instance):
    preg_replace (‘/(( \ w + \ W *) {199} (\ w +))(.*)/’, ‘$ {1} ‘, $ post-> post_content);

    199 – number of words (start from 0)

Viewing 1 replies (of 1 total)
  • The topic ‘How to trim post’ is closed to new replies.