• hi everybody,

    by default the index page of wordpress blog will show all content of per post, I’d like only show before 100 charactors of all content of one post then user can click ‘more details’ to direct the details page to view all content, I don’t want use the_excerpt() within shemes, this is caused by some post has not summary, I tried to use the_content but found it’s not aviaible, everybody have a way to implement it? I’m used the latest version wordpress.

    thanks

Viewing 8 replies - 1 through 8 (of 8 total)
  • Try using the <!-more--> tag in post along with <?php the_content();> in the index.php template file.

    Thread Starter jammychen

    (@jammychen)

    how to use it? could you give me a example? thanks

    Thread Starter jammychen

    (@jammychen)

    following the codex document I use
    <div class=”PostContent”>
    <?php the_content(‘Read the rest of this entry »’); ?>
    </div>
    it display all contents
    <div class=”PostContent”>
    <?php the_content(”,FALSE,”); ?>
    </div>
    it also dispaly all contents, I am confused, anybody who can teach me how use the tag to display only the first 100 charactors of every post in the index page templet

    Use get_the_content() so you can manipulate before echo. 0 is the starting point, 100 is how many char from the starting point you want to show. Also do strip_tags so you don’t get broken html when the chars of the post content is reduced.

    <div class="entry">
    <?php echo substr(strip_tags(get_the_content()),0,100); ?>
    <a href="<?php echo get_permalink(); ?>">Read More</a>
    </div>

    Limit the words in the post. This way it looks nicer without words getting cut off. This does 20 words.

    <div class="entry">
    <?php
    $words = explode(" ",strip_tags(get_the_content()));
    $content = implode(" ",array_splice($words,0,20));
    echo $content;
    ?>
     <a href="<?php echo get_permalink(); ?>">Read More</a>
    </div>

    It seems that the get_the_content function won’t display images in a post… So this doesn’t fully work from my perspective. Any thoughts? Thanks!

    If you are using the strip_tags( then images won’t show; it removes HTML. If you don’t use strip_tags when doing a simple substr then you could end up with something like this Look at this picture! <img src=" …end.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘I want to cut before 100 charactors of content of per post’ is closed to new replies.