• Resolved ajcke

    (@emerinea)


    I have posts in the a category of “news” posting to my sidebar.php. I would like to limit the number of characters by replacing <?php the_content(); ?> with something that will limit the number of characters and number of posts. I’ve tried some plugins but they limit the number of characters for my posts on my main page. Also some of the plugins conflict with the image I want displayed in each post.

    Here’s the webpage: http://blog.hardinnorthern.org

    Any suggestions?

    Thanks,
    Andy

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter ajcke

    (@emerinea)

    I figured out how to limit the number of posts. I’m just not sure about limiting the number of characters.

    Yes I am also looking for the same thing. Can WP do that on its own or I have to strip out some content manually with php code?

    MichaelH

    (@michaelh)

    Limiting the number of posts could be as simple as using the showposts argument with template tag, query_posts().

    In a post loop

    <?php
    echo 'truncated post content to 50 chars ' . substr($post->content,0,50);
    ?>

    Now I have placed my custom function in the functions.php but it seems that the file is not being loaded. I am working on localhost. Any idea?

    MichaelH

    (@michaelh)

    ashfame – please start another topic with your question.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘PHP Character Limit’ is closed to new replies.